Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
compositesessionmanager.php
1<?php
2
3namespace Bitrix\Main\Session;
4
6
8{
9 public const EVENT_REGENERATE_SESSION_ID = 'onRegenerateSessionId';
10
12 private $kernelSession;
14 private $session;
15
21 public function __construct(SessionInterface $kernelSession, SessionInterface $session)
22 {
23 $this->kernelSession = $kernelSession;
24 $this->session = $session;
25 }
26
27 public function start(): void
28 {
29 if (!$this->kernelSession->isStarted())
30 {
31 $this->kernelSession->start();
32 }
33 if (!$this->session->isStarted())
34 {
35 $this->session->start();
36 }
37 }
38
39 public function destroy(): void
40 {
41 $this->start();
42
43 if ($this->kernelSession instanceof KernelSessionProxy)
44 {
45 $this->kernelSession->destroy();
46
47 return;
48 }
49
50 $this->kernelSession->destroy();
51 $this->session->destroy();
52 }
53
54 public function clear(): void
55 {
56 $this->start();
57
58 if ($this->kernelSession instanceof KernelSessionProxy)
59 {
60 $this->kernelSession->clear();
61
62 return;
63 }
64
65 $this->kernelSession->clear();
66 $this->session->clear();
67 }
68
69 public function regenerateId(): void
70 {
71 $this->start();
72
73 $this->kernelSession->regenerateId();
74 if (!($this->kernelSession instanceof KernelSessionProxy))
75 {
76 $this->session->regenerateId();
77 }
78
79 (new Event('main', self::EVENT_REGENERATE_SESSION_ID, [
80 'newSessionId' => $this->kernelSession->getId(),
81 ]))->send();
82 }
83}
__construct(SessionInterface $kernelSession, SessionInterface $session)