Session (Component\HttpFoundation\Session)
Symfony\Component\HttpFoundation\Session\Session
class Session implements SessionInterface, IteratorAggregate, Countable
Session.
Methods
__construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null) Constructor. | ||
bool | start() Starts the session storage. | |
bool | has(string $name) Checks if an attribute is defined. | |
mixed | get(string $name, mixed $default = null) Returns an attribute. | |
set(string $name, mixed $value) Sets an attribute. | ||
array | all() Returns attributes. | |
replace(array $attributes) Sets attributes. | ||
mixed | remove(string $name) Removes an attribute. | |
clear() Clears all attributes. | ||
bool | isStarted() Checks if the session was started. | |
ArrayIterator | getIterator() Returns an iterator for attributes. | |
int | count() Returns the number of attributes. | |
bool | invalidate(int $lifetime = null) Invalidates the current session. | |
bool | migrate(bool $destroy = false, int $lifetime = null) Migrates the current session to a new session id while maintaining all session attributes. | |
save() Force the session to be saved and closed. | ||
string | getId() Returns the session ID. | |
setId(string $id) Sets the session ID. | ||
mixed | getName() Returns the session name. | |
setName(string $name) Sets the session name. | ||
MetadataBag | getMetadataBag() Gets session meta. | |
registerBag(SessionBagInterface $bag) Registers a SessionBagInterface with the session. | ||
SessionBagInterface | getBag(string $name) Gets a bag instance by name. | |
FlashBagInterface | getFlashBag() Gets the flashbag interface. |
Details
public __construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
Constructor.
public bool start()
Starts the session storage.
public bool has(string $name)
Checks if an attribute is defined.
public mixed get(string $name, mixed $default = null)
Returns an attribute.
public set(string $name, mixed $value)
Sets an attribute.
public array all()
Returns attributes.
public replace(array $attributes)
Sets attributes.
public mixed remove(string $name)
Removes an attribute.
public clear()
Clears all attributes.
public bool isStarted()
Checks if the session was started.
public ArrayIterator getIterator()
Returns an iterator for attributes.
public int count()
Returns the number of attributes.
public bool invalidate(int $lifetime = null)
Invalidates the current session.
Clears all session attributes and flashes and regenerates the session and deletes the old session from persistence.
public bool migrate(bool $destroy = false, int $lifetime = null)
Migrates the current session to a new session id while maintaining all session attributes.
public save()
Force the session to be saved and closed.
This method is generally not required for real sessions as the session will be automatically saved at the end of code execution.
public string getId()
Returns the session ID.
public setId(string $id)
Sets the session ID.
public mixed getName()
Returns the session name.
public setName(string $name)
Sets the session name.
public MetadataBag getMetadataBag()
Gets session meta.
public registerBag(SessionBagInterface $bag)
Registers a SessionBagInterface with the session.
public SessionBagInterface getBag(string $name)
Gets a bag instance by name.
public FlashBagInterface getFlashBag()
Gets the flashbag interface.
© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/3.0/Symfony/Component/HttpFoundation/Session/Session.html