bitrix-sessions

Implement Bitrix session handling via Application::getInstance()->getSession() with multi-backend storage.

33|3|Updated Jun 5, 2025
One-click install
npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-sessions
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: bitrix-sessions
Source: https://github.com/bxmaximum/bitrix_ai_challenge/tree/main/.agents/skills/bitrix-sessions
Command: npx skills add https://github.com/bxmaximum/bitrix_ai_challenge --skill bitrix-sessions

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Bitrix session handling is error-prone when developers bypass the Session API and touch global $_SESSION directly. This Skill provides a consistent, secure interface using Bitrix\Main\Application::getInstance()->getSession() and related tools, preventing issues like read-only modes, kernel vs local sessions, and separated session storage.

Core Features & Use Cases

  • Use Application::getInstance()->getSession() to safely read/write session data via ArrayAccess.
  • Leverage Kernel sessions, Local storage sessions, and separated mode to optimize performance and scale.
  • Switch storage backends (redis, memcache, database, file) with sane defaults and automated persistence.
  • Enforce security practices like regenerating session IDs after login and avoiding direct use of $_SESSION in code.
  • Typical use cases: shopping carts, user preferences, per-user flags, CSRF protection.

Quick Start

Use Application::getInstance()->getSession() to manage your app session instead of $_SESSION.

Frequently Asked Questions about bitrix-sessions

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I securely handle Bitrix sessions instead of using global $_SESSION?

To securely handle Bitrix sessions, use Application::getInstance()->getSession() to access the Session API via ArrayAccess. This prevents issues caused by directly manipulating the global $_SESSION variable and ensures safe read and write operations.

Can I use Redis or Memcache for Bitrix session storage?

Yes, you can use Redis, Memcache, database, or file backends for Bitrix session storage. The Session API supports switching between these multi-backend storage options to optimize performance and scale.

What is the difference between kernel and local sessions in Bitrix?

Kernel and local sessions in Bitrix separate core framework data from custom module data. Using separated modes and the Session API optimizes performance by isolating kernel session handling from local storage sessions.

How do I regenerate session IDs after login in Bitrix?

Regenerate session IDs after login by applying the Bitrix Session API security practices. This enforcement prevents session fixation attacks and is supported natively when you manage sessions via Application::getInstance()->getSession().

Does Bitrix session handling support read-only modes?

Yes, Bitrix session handling supports Readonly modes through the Session API. This allows you to safely read session data without initiating write operations, preventing accidental modifications to the session state.

Why should I avoid direct $_SESSION manipulation in Bitrix applications?

Avoiding direct $_SESSION manipulation in Bitrix prevents errors with read-only modes, kernel vs local separation, and multi-backend storage. Using the Bitrix Session API ensures consistent, secure, and performant session handling.