Views: 2423
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.

General principle

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:

  1. Data, used on each hit are implemented in KernelSession-session ("hot" data). This data is for authentication, authentication and other kernel-related data.
  2. All the rest that is stored in session - is the "cold" data.
  3. KernelSession-session is non-blocking.
  4. All the rest - a standard blocking session.
  5. 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.

Storage settings

To enable a divided session mode, you need to change session[mode] to separated in bitrix/.settings.php. Add 'kernel' => 'encrypted_cookies' and 'lifetime' => 14400,.

Examples can be found here.

Courses developed by Bitrix24