Session
class Session implements SessionInterface, IteratorAggregate, Countable
Session.
Methods
Constructor.
Starts the session storage.
Checks if an attribute is defined.
Returns an attribute.
Sets an attribute.
Returns attributes.
Sets attributes.
Removes an attribute.
Clears all attributes.
Checks if the session was started.
Returns an iterator for attributes.
Returns the number of attributes.
Invalidates the current session.
Migrates the current session to a new session id while maintaining all session attributes.
Force the session to be saved and closed.
Returns the session ID.
Sets the session ID.
Returns the session name.
Sets the session name.
Gets session meta.
Gets a bag instance by name.
Gets the flashbag interface.
Details
at line line 53
__construct(SessionStorageInterface $storage = null, AttributeBagInterface $attributes = null, FlashBagInterface $flashes = null)
Constructor.
at line line 69
bool
start()
Starts the session storage.
at line line 77
bool
has(string $name)
Checks if an attribute is defined.
at line line 85
mixed
get(string $name, mixed $default = null)
Returns an attribute.
at line line 93
set(string $name, mixed $value)
Sets an attribute.
at line line 101
array
all()
Returns attributes.
at line line 109
replace(array $attributes)
Sets attributes.
at line line 117
mixed
remove(string $name)
Removes an attribute.
at line line 125
clear()
Clears all attributes.
at line line 133
bool
isStarted()
Checks if the session was started.
at line line 143
ArrayIterator
getIterator()
Returns an iterator for attributes.
at line line 153
int
count()
Returns the number of attributes.
at line line 161
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.
at line line 171
bool
migrate(bool $destroy = false, int $lifetime = null)
Migrates the current session to a new session id while maintaining all session attributes.
at line line 179
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.
at line line 187
string
getId()
Returns the session ID.
at line line 195
setId(string $id)
Sets the session ID.
at line line 203
mixed
getName()
Returns the session name.
at line line 211
setName(string $name)
Sets the session name.
at line line 219
MetadataBag
getMetadataBag()
Gets session meta.
at line line 227
registerBag(SessionBagInterface $bag)
Registers a SessionBagInterface with the session.
at line line 235
SessionBagInterface
getBag(string $name)
Gets a bag instance by name.
at line line 245
FlashBagInterface
getFlashBag()
Gets the flashbag interface.