To work with the session, the standard symfony mechanism is used:
https://symfony.com/doc/current/session.html
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 \XLite\Core\Session
.
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 \XLite\Core\Session::getInstance()
$session = \XLite\Core\Session::getInstance();
$session->some_filed = 'some_value';
$someVar = $session->some_other_field;