Session and cookies
Sessions in Magento
conform to Magento\Framework\Session\SessionManagerInterface
. In the app/etc/di.xml
file, there is a definition preference for the SessionManagerInterface
class which points to the Magento\Framework\Session\Generic
class type. The Session\Generic
class is just an empty class that extends the Magento\Framework\Session\SessionManager
class, which in turn implements the SessionManagerInterface
class.
There is one important object that gets instantiated in the SessionManager
instance that conforms to \Magento\Framework\Session\Config\ConfigInterface
. On looking at app/etc/di.xml
file, we can see a preference for ConfigInterface
pointing to a Magento\Framework\Session\Config
class type.
Tip
To fully understand the session behavior in Magento
, we should study the inner workings of both the SessionManager
and Session\Config
classes.
Magento
uses cookies to keep track of a session. These cookies have a default lifetime of 3,600 seconds. When a session is established...