Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
databasesessionhandler.php
1
<?php
2
3
namespace
Bitrix\Main\Session\Handlers
;
4
5
use
Bitrix\Main\Session\Handlers\Table\UserSessionTable
;
6
7
class
DatabaseSessionHandler
extends
AbstractSessionHandler
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
{
38
$this->
processDestroy
(
$sessionId
);
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
{
69
UserSessionTable::deleteOlderThan
($maxLifeTime);
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
}
Bitrix\Main\Session\Handlers\AbstractSessionHandler
Definition
abstractsessionhandler.php:11
Bitrix\Main\Session\Handlers\AbstractSessionHandler\$sessionId
$sessionId
Definition
abstractsessionhandler.php:17
Bitrix\Main\Session\Handlers\DatabaseSessionHandler
Definition
databasesessionhandler.php:8
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\__construct
__construct(array $options)
Definition
databasesessionhandler.php:9
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\processWrite
processWrite($sessionId, $sessionData)
Definition
databasesessionhandler.php:36
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\lock
lock($sessionId)
Definition
databasesessionhandler.php:48
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\updateTimestamp
updateTimestamp($sessionId, $sessionData)
Definition
databasesessionhandler.php:74
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\processRead
processRead($sessionId)
Definition
databasesessionhandler.php:19
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\processDestroy
processDestroy($sessionId)
Definition
databasesessionhandler.php:58
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\unlock
unlock($sessionId)
Definition
databasesessionhandler.php:53
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\open
open($savePath, $sessionName)
Definition
databasesessionhandler.php:14
Bitrix\Main\Session\Handlers\DatabaseSessionHandler\gc
gc($maxLifeTime)
Definition
databasesessionhandler.php:67
Bitrix\Main\Session\Handlers\Table\UserSessionTable
Definition
usersessiontable.php:27
Bitrix\Main\Session\Handlers\Table\UserSessionTable\lock
static lock($id, $timeout=60)
Definition
usersessiontable.php:105
Bitrix\Main\Session\Handlers\Table\UserSessionTable\deleteOlderThan
static deleteOlderThan($sec)
Definition
usersessiontable.php:159
Bitrix\Main\Session\Handlers\Table\UserSessionTable\unlock
static unlock($id)
Definition
usersessiontable.php:133
Bitrix\Main\Type\DateTime
Definition
datetime.php:9
Bitrix\Main\Session\Handlers
Definition
abstractsessionhandler.php:3
Bitrix\Main\Type
Definition
collection.php:2
Bitrix
modules
main
lib
session
handlers
databasesessionhandler.php
Создано системой
1.10.0