Chris@0: Chris@0: * Chris@0: * For the full copyright and license information, please view the LICENSE Chris@0: * file that was distributed with this source code. Chris@0: */ Chris@0: Chris@0: namespace Symfony\Component\HttpFoundation\Session\Storage; Chris@0: Chris@0: use Symfony\Component\HttpFoundation\Session\SessionBagInterface; Chris@0: Chris@0: /** Chris@0: * StorageInterface. Chris@0: * Chris@0: * @author Fabien Potencier Chris@0: * @author Drak Chris@0: */ Chris@0: interface SessionStorageInterface Chris@0: { Chris@0: /** Chris@0: * Starts the session. Chris@0: * Chris@0: * @return bool True if started Chris@0: * Chris@14: * @throws \RuntimeException if something goes wrong starting the session Chris@0: */ Chris@0: public function start(); Chris@0: Chris@0: /** Chris@0: * Checks if the session is started. Chris@0: * Chris@0: * @return bool True if started, false otherwise Chris@0: */ Chris@0: public function isStarted(); Chris@0: Chris@0: /** Chris@0: * Returns the session ID. Chris@0: * Chris@0: * @return string The session ID or empty Chris@0: */ Chris@0: public function getId(); Chris@0: Chris@0: /** Chris@0: * Sets the session ID. Chris@0: * Chris@0: * @param string $id Chris@0: */ Chris@0: public function setId($id); Chris@0: Chris@0: /** Chris@0: * Returns the session name. Chris@0: * Chris@0: * @return mixed The session name Chris@0: */ Chris@0: public function getName(); Chris@0: Chris@0: /** Chris@0: * Sets the session name. Chris@0: * Chris@0: * @param string $name Chris@0: */ Chris@0: public function setName($name); Chris@0: Chris@0: /** Chris@0: * Regenerates id that represents this storage. Chris@0: * Chris@0: * This method must invoke session_regenerate_id($destroy) unless Chris@0: * this interface is used for a storage object designed for unit Chris@0: * or functional testing where a real PHP session would interfere Chris@0: * with testing. Chris@0: * Chris@0: * Note regenerate+destroy should not clear the session data in memory Chris@0: * only delete the session data from persistent storage. Chris@0: * Chris@0: * Care: When regenerating the session ID no locking is involved in PHP's Chris@0: * session design. See https://bugs.php.net/bug.php?id=61470 for a discussion. Chris@0: * So you must make sure the regenerated session is saved BEFORE sending the Chris@0: * headers with the new ID. Symfony's HttpKernel offers a listener for this. Chris@0: * See Symfony\Component\HttpKernel\EventListener\SaveSessionListener. Chris@0: * Otherwise session data could get lost again for concurrent requests with the Chris@0: * new ID. One result could be that you get logged out after just logging in. Chris@0: * Chris@0: * @param bool $destroy Destroy session when regenerating? Chris@0: * @param int $lifetime Sets the cookie lifetime for the session cookie. A null value Chris@0: * will leave the system settings unchanged, 0 sets the cookie Chris@0: * to expire with browser session. Time is in seconds, and is Chris@0: * not a Unix timestamp. Chris@0: * Chris@0: * @return bool True if session regenerated, false if error Chris@0: * Chris@0: * @throws \RuntimeException If an error occurs while regenerating this storage Chris@0: */ Chris@0: public function regenerate($destroy = false, $lifetime = null); Chris@0: Chris@0: /** Chris@0: * Force the session to be saved and closed. Chris@0: * Chris@0: * This method must invoke session_write_close() unless this interface is Chris@0: * used for a storage object design for unit or functional testing where Chris@0: * a real PHP session would interfere with testing, in which case Chris@0: * it should actually persist the session data if required. Chris@0: * Chris@14: * @throws \RuntimeException if the session is saved without being started, or if the session Chris@14: * is already closed Chris@0: */ Chris@0: public function save(); Chris@0: Chris@0: /** Chris@0: * Clear all session data in memory. Chris@0: */ Chris@0: public function clear(); Chris@0: Chris@0: /** Chris@0: * Gets a SessionBagInterface by name. Chris@0: * Chris@0: * @param string $name Chris@0: * Chris@0: * @return SessionBagInterface Chris@0: * Chris@0: * @throws \InvalidArgumentException If the bag does not exist Chris@0: */ Chris@0: public function getBag($name); Chris@0: Chris@0: /** Chris@0: * Registers a SessionBagInterface for use. Chris@0: */ Chris@0: public function registerBag(SessionBagInterface $bag); Chris@0: Chris@0: /** Chris@0: * @return MetadataBag Chris@0: */ Chris@0: public function getMetadataBag(); Chris@0: }