Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
databasesessionhandler.php
1<?php
2
4
6
8{
9 public function __construct(array $options)
10 {
11 $this->readOnly = $options['readOnly'] ?? false; //defined('BX_SECURITY_SESSION_READONLY');
12 }
13
14 public function open($savePath, $sessionName): bool
15 {
16 return true;
17 }
18
19 public function processRead($sessionId): string
20 {
21 $sessionRow = UserSessionTable::getRow([
22 'select' => ['SESSION_DATA'],
23 'filter' => [
24 '=SESSION_ID' => $sessionId
25 ]
26 ]);
27
28 if (isset($sessionRow['SESSION_DATA']))
29 {
30 return base64_decode($sessionRow['SESSION_DATA']);
31 }
32
33 return '';
34 }
35
36 public function processWrite($sessionId, $sessionData): bool
37 {
39 $result = UserSessionTable::add([
40 'SESSION_ID' => $sessionId,
41 'TIMESTAMP_X' => new \Bitrix\Main\Type\DateTime(),
42 'SESSION_DATA' => base64_encode($sessionData),
43 ]);
44
45 return $result->isSuccess();
46 }
47
48 protected function lock($sessionId): bool
49 {
50 return UserSessionTable::lock($this->sessionId);
51 }
52
53 protected function unlock($sessionId): bool
54 {
55 return UserSessionTable::unlock($this->sessionId);
56 }
57
58 protected function processDestroy($sessionId): bool
59 {
60 return UserSessionTable::delete($sessionId)->isSuccess();
61 }
62
67 public function gc($maxLifeTime): int
68 {
70
71 return 0;
72 }
73
74 public function updateTimestamp($sessionId, $sessionData): bool
75 {
76 $result = UserSessionTable::update($sessionId, [
77 'TIMESTAMP_X' => new \Bitrix\Main\Type\DateTime(),
78 ]);
79
80 return $result->isSuccess();
81 }
82}