Subversion Repositories php-qbpwcf

Rev

Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
3 liveuser 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;
13
 
14
use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
15
 
16
/**
17
 * Interface for the session.
18
 *
19
 * @author Drak <drak@zikula.org>
20
 */
21
interface SessionInterface
22
{
23
    /**
24
     * Starts the session storage.
25
     *
26
     * @return bool
27
     *
28
     * @throws \RuntimeException if session fails to start
29
     */
30
    public function start();
31
 
32
    /**
33
     * Returns the session ID.
34
     *
35
     * @return string
36
     */
37
    public function getId();
38
 
39
    /**
40
     * Sets the session ID.
41
     */
42
    public function setId(string $id);
43
 
44
    /**
45
     * Returns the session name.
46
     *
47
     * @return string
48
     */
49
    public function getName();
50
 
51
    /**
52
     * Sets the session name.
53
     */
54
    public function setName(string $name);
55
 
56
    /**
57
     * Invalidates the current session.
58
     *
59
     * Clears all session attributes and flashes and regenerates the
60
     * session and deletes the old session from persistence.
61
     *
62
     * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value
63
     *                      will leave the system settings unchanged, 0 sets the cookie
64
     *                      to expire with browser session. Time is in seconds, and is
65
     *                      not a Unix timestamp.
66
     *
67
     * @return bool
68
     */
69
    public function invalidate(int $lifetime = null);
70
 
71
    /**
72
     * Migrates the current session to a new session id while maintaining all
73
     * session attributes.
74
     *
75
     * @param bool $destroy  Whether to delete the old session or leave it to garbage collection
76
     * @param int  $lifetime Sets the cookie lifetime for the session cookie. A null value
77
     *                       will leave the system settings unchanged, 0 sets the cookie
78
     *                       to expire with browser session. Time is in seconds, and is
79
     *                       not a Unix timestamp.
80
     *
81
     * @return bool
82
     */
83
    public function migrate(bool $destroy = false, int $lifetime = null);
84
 
85
    /**
86
     * Force the session to be saved and closed.
87
     *
88
     * This method is generally not required for real sessions as
89
     * the session will be automatically saved at the end of
90
     * code execution.
91
     */
92
    public function save();
93
 
94
    /**
95
     * Checks if an attribute is defined.
96
     *
97
     * @return bool
98
     */
99
    public function has(string $name);
100
 
101
    /**
102
     * Returns an attribute.
103
     *
104
     * @param mixed $default The default value if not found
105
     *
106
     * @return mixed
107
     */
108
    public function get(string $name, $default = null);
109
 
110
    /**
111
     * Sets an attribute.
112
     *
113
     * @param mixed $value
114
     */
115
    public function set(string $name, $value);
116
 
117
    /**
118
     * Returns attributes.
119
     *
120
     * @return array
121
     */
122
    public function all();
123
 
124
    /**
125
     * Sets attributes.
126
     */
127
    public function replace(array $attributes);
128
 
129
    /**
130
     * Removes an attribute.
131
     *
132
     * @return mixed The removed value or null when it does not exist
133
     */
134
    public function remove(string $name);
135
 
136
    /**
137
     * Clears all attributes.
138
     */
139
    public function clear();
140
 
141
    /**
142
     * Checks if the session was started.
143
     *
144
     * @return bool
145
     */
146
    public function isStarted();
147
 
148
    /**
149
     * Registers a SessionBagInterface with the session.
150
     */
151
    public function registerBag(SessionBagInterface $bag);
152
 
153
    /**
154
     * Gets a bag instance by name.
155
     *
156
     * @return SessionBagInterface
157
     */
158
    public function getBag(string $name);
159
 
160
    /**
161
     * Gets session meta.
162
     *
163
     * @return MetadataBag
164
     */
165
    public function getMetadataBag();
166
}