comparison vendor/symfony/http-foundation/Session/Storage/Proxy/AbstractProxy.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children 1fec387a4317
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
13
14 /**
15 * AbstractProxy.
16 *
17 * @author Drak <drak@zikula.org>
18 */
19 abstract class AbstractProxy
20 {
21 /**
22 * Flag if handler wraps an internal PHP session handler (using \SessionHandler).
23 *
24 * @var bool
25 */
26 protected $wrapper = false;
27
28 /**
29 * @var string
30 */
31 protected $saveHandlerName;
32
33 /**
34 * Gets the session.save_handler name.
35 *
36 * @return string
37 */
38 public function getSaveHandlerName()
39 {
40 return $this->saveHandlerName;
41 }
42
43 /**
44 * Is this proxy handler and instance of \SessionHandlerInterface.
45 *
46 * @return bool
47 */
48 public function isSessionHandlerInterface()
49 {
50 return $this instanceof \SessionHandlerInterface;
51 }
52
53 /**
54 * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
55 *
56 * @return bool
57 */
58 public function isWrapper()
59 {
60 return $this->wrapper;
61 }
62
63 /**
64 * Has a session started?
65 *
66 * @return bool
67 */
68 public function isActive()
69 {
70 return \PHP_SESSION_ACTIVE === session_status();
71 }
72
73 /**
74 * Gets the session ID.
75 *
76 * @return string
77 */
78 public function getId()
79 {
80 return session_id();
81 }
82
83 /**
84 * Sets the session ID.
85 *
86 * @param string $id
87 *
88 * @throws \LogicException
89 */
90 public function setId($id)
91 {
92 if ($this->isActive()) {
93 throw new \LogicException('Cannot change the ID of an active session');
94 }
95
96 session_id($id);
97 }
98
99 /**
100 * Gets the session name.
101 *
102 * @return string
103 */
104 public function getName()
105 {
106 return session_name();
107 }
108
109 /**
110 * Sets the session name.
111 *
112 * @param string $name
113 *
114 * @throws \LogicException
115 */
116 public function setName($name)
117 {
118 if ($this->isActive()) {
119 throw new \LogicException('Cannot change the name of an active session');
120 }
121
122 session_name($name);
123 }
124 }