bitrix-sessions
Installation
SKILL.md
Sessions
Baseline: main 23.0+ · Verified: main 26.800.0
Never touch $_SESSION: it bypasses lazy start, read-only and virtual modes.
use Bitrix\Main\Application;
$session = Application::getInstance()->getSession(); // SessionInterface + ArrayAccess
$session->set('vendor.wizard', ['step' => 2]);
$state = $session->get('vendor.wizard'); // null if missing
if ($session->has('vendor.flash')) { $msg = $session->get('vendor.flash'); $session->remove('vendor.flash'); }
$session->regenerateId(); // after login / privilege change
- Prefix keys with your module id; store scalars/arrays only.
- The session is written and closed before background jobs and agents run: writes from
addBackgroundJob()are lost (bitrix-background-jobs). CLI, agents and Messenger have no session.