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 Boolean True if session started.
27: *
28: * @throws \RuntimeException If session fails to start.
29: *
30: * @api
31: */
32: public function start();
33:
34: /**
35: * Returns the session ID.
36: *
37: * @return string The session ID.
38: *
39: * @api
40: */
41: public function getId();
42:
43: /**
44: * Sets the session ID
45: *
46: * @param string $id
47: *
48: * @api
49: */
50: public function setId($id);
51:
52: /**
53: * Returns the session name.
54: *
55: * @return mixed The session name.
56: *
57: * @api
58: */
59: public function getName();
60:
61: /**
62: * Sets the session name.
63: *
64: * @param string $name
65: *
66: * @api
67: */
68: public function setName($name);
69:
70: /**
71: * Invalidates the current session.
72: *
73: * Clears all session attributes and flashes and regenerates the
74: * session and deletes the old session from persistence.
75: *
76: * @param integer $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 Boolean True if session invalidated, false if error.
82: *
83: * @api
84: */
85: public function invalidate($lifetime = null);
86:
87: /**
88: * Migrates the current session to a new session id while maintaining all
89: * session attributes.
90: *
91: * @param Boolean $destroy Whether to delete the old session or leave it to garbage collection.
92: * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
93: * will leave the system settings unchanged, 0 sets the cookie
94: * to expire with browser session. Time is in seconds, and is
95: * not a Unix timestamp.
96: *
97: * @return Boolean True if session migrated, false if error.
98: *
99: * @api
100: */
101: public function migrate($destroy = false, $lifetime = null);
102:
103: /**
104: * Force the session to be saved and closed.
105: *
106: * This method is generally not required for real sessions as
107: * the session will be automatically saved at the end of
108: * code execution.
109: */
110: public function save();
111:
112: /**
113: * Checks if an attribute is defined.
114: *
115: * @param string $name The attribute name
116: *
117: * @return Boolean true if the attribute is defined, false otherwise
118: *
119: * @api
120: */
121: public function has($name);
122:
123: /**
124: * Returns an attribute.
125: *
126: * @param string $name The attribute name
127: * @param mixed $default The default value if not found.
128: *
129: * @return mixed
130: *
131: * @api
132: */
133: public function get($name, $default = null);
134:
135: /**
136: * Sets an attribute.
137: *
138: * @param string $name
139: * @param mixed $value
140: *
141: * @api
142: */
143: public function set($name, $value);
144:
145: /**
146: * Returns attributes.
147: *
148: * @return array Attributes
149: *
150: * @api
151: */
152: public function all();
153:
154: /**
155: * Sets attributes.
156: *
157: * @param array $attributes Attributes
158: */
159: public function replace(array $attributes);
160:
161: /**
162: * Removes an attribute.
163: *
164: * @param string $name
165: *
166: * @return mixed The removed value
167: *
168: * @api
169: */
170: public function remove($name);
171:
172: /**
173: * Clears all attributes.
174: *
175: * @api
176: */
177: public function clear();
178:
179: /**
180: * Checks if the session was started.
181: *
182: * @return Boolean
183: */
184: public function isStarted();
185:
186: /**
187: * Registers a SessionBagInterface with the session.
188: *
189: * @param SessionBagInterface $bag
190: */
191: public function registerBag(SessionBagInterface $bag);
192:
193: /**
194: * Gets a bag instance by name.
195: *
196: * @param string $name
197: *
198: * @return SessionBagInterface
199: */
200: public function getBag($name);
201:
202: /**
203: * Gets session meta.
204: *
205: * @return MetadataBag
206: */
207: public function getMetadataBag();
208: }
209: