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; Chris@0: Chris@0: use Symfony\Component\HttpFoundation\Session\Storage\MetadataBag; Chris@0: Chris@0: /** Chris@0: * Interface for the session. Chris@0: * Chris@0: * @author Drak Chris@0: */ Chris@0: interface SessionInterface Chris@0: { Chris@0: /** Chris@0: * Starts the session storage. Chris@0: * Chris@0: * @return bool True if session started Chris@0: * Chris@14: * @throws \RuntimeException if session fails to start Chris@0: */ Chris@0: public function start(); Chris@0: Chris@0: /** Chris@0: * Returns the session ID. Chris@0: * Chris@0: * @return string The session ID 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: * Invalidates the current session. Chris@0: * Chris@0: * Clears all session attributes and flashes and regenerates the Chris@0: * session and deletes the old session from persistence. Chris@0: * 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 invalidated, false if error Chris@0: */ Chris@0: public function invalidate($lifetime = null); Chris@0: Chris@0: /** Chris@0: * Migrates the current session to a new session id while maintaining all Chris@0: * session attributes. Chris@0: * Chris@0: * @param bool $destroy Whether to delete the old session or leave it to garbage collection 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 migrated, false if error Chris@0: */ Chris@0: public function migrate($destroy = false, $lifetime = null); Chris@0: Chris@0: /** Chris@0: * Force the session to be saved and closed. Chris@0: * Chris@0: * This method is generally not required for real sessions as Chris@0: * the session will be automatically saved at the end of Chris@0: * code execution. Chris@0: */ Chris@0: public function save(); Chris@0: Chris@0: /** Chris@0: * Checks if an attribute is defined. Chris@0: * Chris@0: * @param string $name The attribute name Chris@0: * Chris@0: * @return bool true if the attribute is defined, false otherwise Chris@0: */ Chris@0: public function has($name); Chris@0: Chris@0: /** Chris@0: * Returns an attribute. Chris@0: * Chris@0: * @param string $name The attribute name Chris@0: * @param mixed $default The default value if not found Chris@0: * Chris@0: * @return mixed Chris@0: */ Chris@0: public function get($name, $default = null); Chris@0: Chris@0: /** Chris@0: * Sets an attribute. Chris@0: * Chris@0: * @param string $name Chris@0: * @param mixed $value Chris@0: */ Chris@0: public function set($name, $value); Chris@0: Chris@0: /** Chris@0: * Returns attributes. Chris@0: * Chris@0: * @return array Attributes Chris@0: */ Chris@0: public function all(); Chris@0: Chris@0: /** Chris@0: * Sets attributes. Chris@0: * Chris@0: * @param array $attributes Attributes Chris@0: */ Chris@0: public function replace(array $attributes); Chris@0: Chris@0: /** Chris@0: * Removes an attribute. Chris@0: * Chris@0: * @param string $name Chris@0: * Chris@0: * @return mixed The removed value or null when it does not exist Chris@0: */ Chris@0: public function remove($name); Chris@0: Chris@0: /** Chris@0: * Clears all attributes. Chris@0: */ Chris@0: public function clear(); Chris@0: Chris@0: /** Chris@0: * Checks if the session was started. Chris@0: * Chris@0: * @return bool Chris@0: */ Chris@0: public function isStarted(); Chris@0: Chris@0: /** Chris@0: * Registers a SessionBagInterface with the session. Chris@0: */ Chris@0: public function registerBag(SessionBagInterface $bag); Chris@0: Chris@0: /** Chris@0: * Gets a bag instance by name. Chris@0: * Chris@0: * @param string $name Chris@0: * Chris@0: * @return SessionBagInterface Chris@0: */ Chris@0: public function getBag($name); Chris@0: Chris@0: /** Chris@0: * Gets session meta. Chris@0: * Chris@0: * @return MetadataBag Chris@0: */ Chris@0: public function getMetadataBag(); Chris@0: }