4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
13 * SessionHandlerInterface for PHP < 5.4.
15 * The order in which these methods are invoked by PHP are:
16 * 1. open [session_start]
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]
23 * Extensive documentation can be found at php.net, see links:
25 * @see http://php.net/sessionhandlerinterface
26 * @see http://php.net/session.customhandler
27 * @see http://php.net/session-set-save-handler
29 * @author Drak <drak@zikula.org>
30 * @author Tobias Schultze <http://tobion.de>
32 interface SessionHandlerInterface
35 * Re-initializes existing session, or creates a new one.
37 * @see http://php.net/sessionhandlerinterface.open
39 * @param string $savePath Save path
40 * @param string $sessionName Session name, see http://php.net/function.session-name.php
42 * @return bool true on success, false on failure
44 public function open($savePath, $sessionName);
47 * Closes the current session.
49 * @see http://php.net/sessionhandlerinterface.close
51 * @return bool true on success, false on failure
53 public function close();
56 * Reads the session data.
58 * @see http://php.net/sessionhandlerinterface.read
60 * @param string $sessionId Session ID, see http://php.net/function.session-id
62 * @return string Same session data as passed in write() or empty string when non-existent or on failure
64 public function read($sessionId);
67 * Writes the session data to the storage.
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().
72 * @see http://php.net/sessionhandlerinterface.write
74 * @param string $sessionId Session ID , see http://php.net/function.session-id
75 * @param string $data Serialized session data to save
77 * @return bool true on success, false on failure
79 public function write($sessionId, $data);
84 * @see http://php.net/sessionhandlerinterface.destroy
86 * @param string $sessionId Session ID, see http://php.net/function.session-id
88 * @return bool true on success, false on failure
90 public function destroy($sessionId);
93 * Cleans up expired sessions (garbage collection).
95 * @see http://php.net/sessionhandlerinterface.gc
97 * @param string|int $maxlifetime Sessions that have not updated for the last maxlifetime seconds will be removed
99 * @return bool true on success, false on failure
101 public function gc($maxlifetime);