1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
kernelsession.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Main\Session;
4
5
use Bitrix\Main\NotSupportedException;
6
use Bitrix\Main\Security\Random;
7
use Bitrix\Main\Session\Handlers\CookieSessionHandler;
8
9
class
KernelSession
implements
SessionInterface
, \ArrayAccess
10
{
11
use
ArrayAccessWithReferences
;
12
13
public
const
COOKIE_NAME
=
'kernel'
;
14
16
protected
$started
;
18
protected
$sessionHandler
;
20
private
$lifetime = 0;
22
private
$id;
24
private
$hash;
25
26
public
function
__construct
(
int
$lifetime = 0)
27
{
28
$this->lifetime = $lifetime;
29
}
30
31
public
function
isActive
(): bool
32
{
33
return
$this->
isStarted
();
34
}
35
36
public
function
isAccessible
(): bool
37
{
38
return
true
;
39
}
40
41
public
function
getId
(): string
42
{
43
return
$this->id;
44
}
45
46
public
function
setId
($id)
47
{
48
throw
new
NotSupportedException
();
49
}
50
51
public
function
getName
(): string
52
{
53
throw
new
NotSupportedException
();
54
}
55
56
public
function
setName
(
$name
)
57
{
58
throw
new
NotSupportedException
();
59
}
60
64
public
function
getSessionHandler
(): \SessionHandlerInterface
65
{
66
return
$this->sessionHandler
;
67
}
68
69
final
protected
function
hashData
(
string
$data
): string
70
{
71
return
hash(
'sha512'
,
$data
);
72
}
73
74
public
function
start
(): bool
75
{
76
if
($this->
isStarted
())
77
{
78
return
true
;
79
}
80
81
$this->started =
true
;
82
$this->sessionHandler =
new
CookieSessionHandler
($this->lifetime);
83
$data
= $this->
getSessionHandler
()->read(self::COOKIE_NAME);
84
$this->hash = $this->
hashData
(
$data
);
85
$this->sessionData = unserialize(
$data
, [
'allowed_classes'
=>
false
]) ?: [];
86
if
(!isset($this->sessionData[
'_id'
]))
87
{
88
$this->sessionData[
'_id'
] = Random::getString(32,
true
);
89
}
90
$this->
id
= $this->sessionData[
'_id'
];
91
92
return
true
;
93
}
94
95
public
function
regenerateId
(): bool
96
{
97
return
true
;
98
}
99
100
public
function
destroy
()
101
{
102
if
($this->
isActive
())
103
{
104
$this->
clear
();
105
}
106
}
107
108
public
function
save
()
109
{
110
$this->
refineReferencesBeforeSave
();
111
$data
= serialize($this->sessionData);
112
113
if
($this->
hashData
(
$data
) !== $this->hash)
114
{
115
$this->
getSessionHandler
()->write(self::COOKIE_NAME,
$data
);
116
}
117
$this->started =
false
;
118
}
119
120
public
function
clear
()
121
{
122
$this->sessionData = [];
123
$this->nullPointers = [];
124
}
125
126
public
function
isStarted
()
127
{
128
return
(
bool
)
$this->started
;
129
}
130
}
Bitrix\Main\NotSupportedException
Определения
NotSupportedException.php:9
Bitrix\Main\Session\Handlers\CookieSessionHandler
Определения
cookiesessionhandler.php:14
Bitrix\Main\Session\KernelSession
Определения
kernelsession.php:10
Bitrix\Main\Session\KernelSession\$started
$started
Определения
kernelsession.php:16
Bitrix\Main\Session\KernelSession\getId
getId()
Определения
kernelsession.php:41
Bitrix\Main\Session\KernelSession\isStarted
isStarted()
Определения
kernelsession.php:126
Bitrix\Main\Session\KernelSession\setName
setName($name)
Определения
kernelsession.php:56
Bitrix\Main\Session\KernelSession\getName
getName()
Определения
kernelsession.php:51
Bitrix\Main\Session\KernelSession\__construct
__construct(int $lifetime=0)
Определения
kernelsession.php:26
Bitrix\Main\Session\KernelSession\regenerateId
regenerateId()
Определения
kernelsession.php:95
Bitrix\Main\Session\KernelSession\getSessionHandler
getSessionHandler()
Определения
kernelsession.php:64
Bitrix\Main\Session\KernelSession\COOKIE_NAME
const COOKIE_NAME
Определения
kernelsession.php:13
Bitrix\Main\Session\KernelSession\setId
setId($id)
Определения
kernelsession.php:46
Bitrix\Main\Session\KernelSession\$sessionHandler
$sessionHandler
Определения
kernelsession.php:18
Bitrix\Main\Session\KernelSession\destroy
destroy()
Определения
kernelsession.php:100
Bitrix\Main\Session\KernelSession\isActive
isActive()
Определения
kernelsession.php:31
Bitrix\Main\Session\KernelSession\clear
clear()
Определения
kernelsession.php:120
Bitrix\Main\Session\KernelSession\isAccessible
isAccessible()
Определения
kernelsession.php:36
Bitrix\Main\Session\KernelSession\hashData
hashData(string $data)
Определения
kernelsession.php:69
Bitrix\Main\Session\KernelSession\start
start()
Определения
kernelsession.php:74
Bitrix\Main\Session\KernelSession\save
save()
Определения
kernelsession.php:108
$data
$data['IS_AVAILABLE']
Определения
.description.php:13
Bitrix\Main\Session\SessionInterface
Определения
sessioninterface.php:6
$name
$name
Определения
menu_edit.php:35
Bitrix\Main\Session\refineReferencesBeforeSave
refineReferencesBeforeSave()
Определения
arrayaccesswithreferences.php:95
Bitrix\Main\Session\ArrayAccessWithReferences
trait ArrayAccessWithReferences
Определения
arrayaccesswithreferences.php:8
bitrix
modules
main
lib
session
kernelsession.php
Создано системой
1.14.0