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: /**
13: * SessionHandlerInterface for PHP < 5.4.
14: *
15: * The order in which these methods are invoked by PHP are:
16: * 1. open [session_start]
17: * 2. read
18: * 3. gc [optional depending on probability settings: gc_probability / gc_divisor]
19: * 4. destroy [optional when session_regenerate_id(true) is used]
20: * 5. write [session_write_close] or destroy [session_destroy]
21: * 6. close
22: *
23: * Extensive documentation can be found at php.net, see links:
24: *
25: * @see http://php.net/sessionhandlerinterface
26: * @see http://php.net/session.customhandler
27: * @see http://php.net/session-set-save-handler
28: *
29: * @author Drak <drak@zikula.org>
30: * @author Tobias Schultze <http://tobion.de>
31: */
32: interface SessionHandlerInterface
33: {
34: /**
35: * Re-initializes existing session, or creates a new one.
36: *
37: * @see http://php.net/sessionhandlerinterface.open
38: *
39: * @param string $savePath Save path
40: * @param string $sessionName Session name, see http://php.net/function.session-name.php
41: *
42: * @return bool true on success, false on failure
43: */
44: public function open($savePath, $sessionName);
45:
46: /**
47: * Closes the current session.
48: *
49: * @see http://php.net/sessionhandlerinterface.close
50: *
51: * @return bool true on success, false on failure
52: */
53: public function close();
54:
55: /**
56: * Reads the session data.
57: *
58: * @see http://php.net/sessionhandlerinterface.read
59: *
60: * @param string $sessionId Session ID, see http://php.net/function.session-id
61: *
62: * @return string Same session data as passed in write() or empty string when non-existent or on failure
63: */
64: public function read($sessionId);
65:
66: /**
67: * Writes the session data to the storage.
68: *
69: * Care, the session ID passed to write() can be different from the one previously
70: * received in read() when the session ID changed due to session_regenerate_id().
71: *
72: * @see http://php.net/sessionhandlerinterface.write
73: *
74: * @param string $sessionId Session ID , see http://php.net/function.session-id
75: * @param string $data Serialized session data to save
76: *
77: * @return bool true on success, false on failure
78: */
79: public function write($sessionId, $data);
80:
81: /**
82: * Destroys a session.
83: *
84: * @see http://php.net/sessionhandlerinterface.destroy
85: *
86: * @param string $sessionId Session ID, see http://php.net/function.session-id
87: *
88: * @return bool true on success, false on failure
89: */
90: public function destroy($sessionId);
91:
92: /**
93: * Cleans up expired sessions (garbage collection).
94: *
95: * @see http://php.net/sessionhandlerinterface.gc
96: *
97: * @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed
98: *
99: * @return bool true on success, false on failure
100: */
101: public function gc($maxlifetime);
102: }
103: