To work with the session, the standard symfony mechanism is used:
Since the session service is private, you cannot get it from the container; you need to use a special service locator.
$session = \XCart\Container::getServiceLocator()->getSession()
In symfony-compatible code (services, event handlers, etc.), you need to use the session handling method described in the symfony documentation.
For backward compatibility in X-Cart 5.5, you can use the class
To access session data, the magic methods set and get are used; that is, you can work with session fields as with fields of an object returned by calling
$session = \XLite\Core\Session::getInstance();
$session->some_filed = 'some_value';
$someVar = $session->some_other_field;