4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\HttpFoundation\Session\Storage\Proxy;
17 * @author Drak <drak@zikula.org>
19 abstract class AbstractProxy
22 * Flag if handler wraps an internal PHP session handler (using \SessionHandler).
26 protected $wrapper = false;
31 protected $active = false;
36 protected $saveHandlerName;
39 * Gets the session.save_handler name.
43 public function getSaveHandlerName()
45 return $this->saveHandlerName;
49 * Is this proxy handler and instance of \SessionHandlerInterface.
53 public function isSessionHandlerInterface()
55 return $this instanceof \SessionHandlerInterface;
59 * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
63 public function isWrapper()
65 return $this->wrapper;
69 * Has a session started?
73 public function isActive()
75 if (PHP_VERSION_ID >= 50400) {
76 return $this->active = \PHP_SESSION_ACTIVE === session_status();
83 * Sets the active flag.
85 * Has no effect under PHP 5.4+ as status is detected
86 * automatically in isActive()
92 * @throws \LogicException
94 public function setActive($flag)
96 if (PHP_VERSION_ID >= 50400) {
97 throw new \LogicException('This method is disabled in PHP 5.4.0+');
100 $this->active = (bool) $flag;
104 * Gets the session ID.
108 public function getId()
114 * Sets the session ID.
118 * @throws \LogicException
120 public function setId($id)
122 if ($this->isActive()) {
123 throw new \LogicException('Cannot change the ID of an active session');
130 * Gets the session name.
134 public function getName()
136 return session_name();
140 * Sets the session name.
142 * @param string $name
144 * @throws \LogicException
146 public function setName($name)
148 if ($this->isActive()) {
149 throw new \LogicException('Cannot change the name of an active session');