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