SessionInterface
in
Interface for the session.
Tags
Table of Contents
- all() : array<string|int, mixed>
- Returns attributes.
- clear() : mixed
- Clears all attributes.
- get() : mixed
- Returns an attribute.
- getBag() : SessionBagInterface
- Gets a bag instance by name.
- getId() : string
- Returns the session ID.
- getMetadataBag() : MetadataBag
- Gets session meta.
- getName() : string
- Returns the session name.
- has() : bool
- Checks if an attribute is defined.
- invalidate() : bool
- Invalidates the current session.
- isStarted() : bool
- Checks if the session was started.
- migrate() : bool
- Migrates the current session to a new session id while maintaining all session attributes.
- registerBag() : mixed
- Registers a SessionBagInterface with the session.
- remove() : mixed
- Removes an attribute.
- replace() : mixed
- Sets attributes.
- save() : mixed
- Force the session to be saved and closed.
- set() : mixed
- Sets an attribute.
- setId() : mixed
- Sets the session ID.
- setName() : mixed
- Sets the session name.
- start() : bool
- Starts the session storage.
Methods
all()
Returns attributes.
public
all() : array<string|int, mixed>
Return values
array<string|int, mixed> —clear()
Clears all attributes.
public
clear() : mixed
Return values
mixed —get()
Returns an attribute.
public
get(string $name[, mixed $default = null ]) : mixed
Parameters
- $name : string
- $default : mixed = null
-
The default value if not found
Return values
mixed —getBag()
Gets a bag instance by name.
public
getBag(string $name) : SessionBagInterface
Parameters
- $name : string
Return values
SessionBagInterface —getId()
Returns the session ID.
public
getId() : string
Return values
string —getMetadataBag()
Gets session meta.
public
getMetadataBag() : MetadataBag
Return values
MetadataBag —getName()
Returns the session name.
public
getName() : string
Return values
string —has()
Checks if an attribute is defined.
public
has(string $name) : bool
Parameters
- $name : string
Return values
bool —invalidate()
Invalidates the current session.
public
invalidate([int|null $lifetime = null ]) : bool
Clears all session attributes and flashes and regenerates the session and deletes the old session from persistence.
Parameters
- $lifetime : int|null = null
-
Sets the cookie lifetime for the session cookie. A null value will leave the system settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds, and is not a Unix timestamp.
Return values
bool —isStarted()
Checks if the session was started.
public
isStarted() : bool
Return values
bool —migrate()
Migrates the current session to a new session id while maintaining all session attributes.
public
migrate([bool $destroy = false ][, int|null $lifetime = null ]) : bool
Parameters
- $destroy : bool = false
-
Whether to delete the old session or leave it to garbage collection
- $lifetime : int|null = null
-
Sets the cookie lifetime for the session cookie. A null value will leave the system settings unchanged, 0 sets the cookie to expire with browser session. Time is in seconds, and is not a Unix timestamp.
Return values
bool —registerBag()
Registers a SessionBagInterface with the session.
public
registerBag(SessionBagInterface $bag) : mixed
Parameters
- $bag : SessionBagInterface
Return values
mixed —remove()
Removes an attribute.
public
remove(string $name) : mixed
Parameters
- $name : string
Return values
mixed —The removed value or null when it does not exist
replace()
Sets attributes.
public
replace(array<string|int, mixed> $attributes) : mixed
Parameters
- $attributes : array<string|int, mixed>
Return values
mixed —save()
Force the session to be saved and closed.
public
save() : mixed
This method is generally not required for real sessions as the session will be automatically saved at the end of code execution.
Return values
mixed —set()
Sets an attribute.
public
set(string $name, mixed $value) : mixed
Parameters
- $name : string
- $value : mixed
Return values
mixed —setId()
Sets the session ID.
public
setId(string $id) : mixed
Parameters
- $id : string
Return values
mixed —setName()
Sets the session name.
public
setName(string $name) : mixed
Parameters
- $name : string
Return values
mixed —start()
Starts the session storage.
public
start() : bool