Last Modified: 18.10.2022
By default, a session in PHP supports a sequential access. it means that the session's parallel hits are blocked and enqueued.
This sequence is convenient for developers, but not always suitable for users, due to possible delays interface and application response. This results in necessity to reduce number of session interruptions.
One of solutions on how to avoid blocking is to write SessionHandlerInterface. This solution, however, is not suitable, due to being excessively used in the Bitrix Framework and Partner-related code.
There is another, better path available:
- Data, used on each hit are implemented in KernelSession-session ("hot" data). This data is for authentication, authentication and other kernel-related data.
- All the rest that is stored in session - is the "cold" data.
- KernelSession-session is non-blocking.
- All the rest - a standard blocking session.
- Blocking session starts only upon first query to cold data.
Division of cold&hot data storage
Encrypted cookies serves as storage for KernelSession session.
Storage for cold session: standard session with the same operational principle as before. That's why the data will be stored in Redis, Memcache, Database.
To enable a divided session mode, you need to change
session[mode] to separated in
'kernel' => 'encrypted_cookies' and
'lifetime' => 14400,.
Examples can be found here.