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;
13:
14: use Symfony\Component\HttpFoundation\Session\SessionBagInterface;
15: use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag;
16:
17: /**
18: * StorageInterface.
19: *
20: * @author Fabien Potencier <fabien@symfony.com>
21: * @author Drak <drak@zikula.org>
22: *
23: * @api
24: */
25: interface SessionStorageInterface
26: {
27: /**
28: * Starts the session.
29: *
30: * @throws \RuntimeException If something goes wrong starting the session.
31: *
32: * @return boolean True if started.
33: *
34: * @api
35: */
36: public function start();
37:
38: /**
39: * Checks if the session is started.
40: *
41: * @return boolean True if started, false otherwise.
42: */
43: public function isStarted();
44:
45: /**
46: * Returns the session ID
47: *
48: * @return string The session ID or empty.
49: *
50: * @api
51: */
52: public function getId();
53:
54: /**
55: * Sets the session ID
56: *
57: * @param string $id
58: *
59: * @api
60: */
61: public function setId($id);
62:
63: /**
64: * Returns the session name
65: *
66: * @return mixed The session name.
67: *
68: * @api
69: */
70: public function getName();
71:
72: /**
73: * Sets the session name
74: *
75: * @param string $name
76: *
77: * @api
78: */
79: public function setName($name);
80:
81: /**
82: * Regenerates id that represents this storage.
83: *
84: * This method must invoke session_regenerate_id($destroy) unless
85: * this interface is used for a storage object designed for unit
86: * or functional testing where a real PHP session would interfere
87: * with testing.
88: *
89: * Note regenerate+destroy should not clear the session data in memory
90: * only delete the session data from persistent storage.
91: *
92: * @param Boolean $destroy Destroy session when regenerating?
93: * @param integer $lifetime Sets the cookie lifetime for the session cookie. A null value
94: * will leave the system settings unchanged, 0 sets the cookie
95: * to expire with browser session. Time is in seconds, and is
96: * not a Unix timestamp.
97: *
98: * @return Boolean True if session regenerated, false if error
99: *
100: * @throws \RuntimeException If an error occurs while regenerating this storage
101: *
102: * @api
103: */
104: public function regenerate($destroy = false, $lifetime = null);
105:
106: /**
107: * Force the session to be saved and closed.
108: *
109: * This method must invoke session_write_close() unless this interface is
110: * used for a storage object design for unit or functional testing where
111: * a real PHP session would interfere with testing, in which case it
112: * it should actually persist the session data if required.
113: *
114: * @throws \RuntimeException If the session is saved without being started, or if the session
115: * is already closed.
116: */
117: public function save();
118:
119: /**
120: * Clear all session data in memory.
121: */
122: public function clear();
123:
124: /**
125: * Gets a SessionBagInterface by name.
126: *
127: * @param string $name
128: *
129: * @return SessionBagInterface
130: *
131: * @throws \InvalidArgumentException If the bag does not exist
132: */
133: public function getBag($name);
134:
135: /**
136: * Registers a SessionBagInterface for use.
137: *
138: * @param SessionBagInterface $bag
139: */
140: public function registerBag(SessionBagInterface $bag);
141:
142: /**
143: * @return MetadataBag
144: */
145: public function getMetadataBag();
146: }
147: