Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 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
 * @author Drak <drak@zikula.org>
16
 */
17
abstract class AbstractProxy
18
{
19
    /**
20
     * Flag if handler wraps an internal PHP session handler (using \SessionHandler).
21
     *
22
     * @var bool
23
     */
24
    protected $wrapper = false;
25
 
26
    /**
27
     * @var string
28
     */
29
    protected $saveHandlerName;
30
 
31
    /**
32
     * Gets the session.save_handler name.
33
     */
34
    public function getSaveHandlerName(): ?string
35
    {
36
        return $this->saveHandlerName;
37
    }
38
 
39
    /**
40
     * Is this proxy handler and instance of \SessionHandlerInterface.
41
     */
42
    public function isSessionHandlerInterface(): bool
43
    {
44
        return $this instanceof \SessionHandlerInterface;
45
    }
46
 
47
    /**
48
     * Returns true if this handler wraps an internal PHP session save handler using \SessionHandler.
49
     */
50
    public function isWrapper(): bool
51
    {
52
        return $this->wrapper;
53
    }
54
 
55
    /**
56
     * Has a session started?
57
     */
58
    public function isActive(): bool
59
    {
60
        return \PHP_SESSION_ACTIVE === session_status();
61
    }
62
 
63
    /**
64
     * Gets the session ID.
65
     */
66
    public function getId(): string
67
    {
68
        return session_id();
69
    }
70
 
71
    /**
72
     * Sets the session ID.
73
     *
74
     * @throws \LogicException
75
     */
76
    public function setId(string $id)
77
    {
78
        if ($this->isActive()) {
79
            throw new \LogicException('Cannot change the ID of an active session.');
80
        }
81
 
82
        session_id($id);
83
    }
84
 
85
    /**
86
     * Gets the session name.
87
     */
88
    public function getName(): string
89
    {
90
        return session_name();
91
    }
92
 
93
    /**
94
     * Sets the session name.
95
     *
96
     * @throws \LogicException
97
     */
98
    public function setName(string $name)
99
    {
100
        if ($this->isActive()) {
101
            throw new \LogicException('Cannot change the name of an active session.');
102
        }
103
 
104
        session_name($name);
105
    }
106
}