Session
in package
implements
SessionInterface, IteratorAggregate, Countable
Tags
Interfaces, Classes and Traits
- SessionInterface
- Interface for the session.
- IteratorAggregate
- Countable
Table of Contents
- $storage : mixed
- $attributeName : mixed
- $data : mixed
- $flashName : mixed
- $usageIndex : mixed
- $usageReporter : mixed
- __construct() : mixed
- all() : array<string|int, mixed>
- Returns attributes.
- clear() : mixed
- Clears all attributes.
- count() : int
- Returns the number of attributes.
- get() : mixed
- Returns an attribute.
- getBag() : SessionBagInterface
- Gets a bag instance by name.
- getFlashBag() : FlashBagInterface
- Gets the flashbag interface.
- getId() : string
- Returns the session ID.
- getIterator() : ArrayIterator<string, mixed>
- Returns an iterator for attributes.
- getMetadataBag() : MetadataBag
- Gets session meta.
- getName() : string
- Returns the session name.
- getUsageIndex() : int
- 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.
- getAttributeBag() : AttributeBagInterface
- Gets the attributebag interface.
Properties
$storage
protected
mixed
$storage
$attributeName
private
mixed
$attributeName
$data
private
mixed
$data
= []
$flashName
private
mixed
$flashName
$usageIndex
private
mixed
$usageIndex
= 0
$usageReporter
private
mixed
$usageReporter
Methods
__construct()
public
__construct([SessionStorageInterface|null $storage = null ][, AttributeBagInterface|null $attributes = null ][, FlashBagInterface|null $flashes = null ][, callable|null $usageReporter = null ]) : mixed
Parameters
- $storage : SessionStorageInterface|null = null
- $attributes : AttributeBagInterface|null = null
- $flashes : FlashBagInterface|null = null
- $usageReporter : callable|null = null
Return values
mixed —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 —count()
Returns the number of attributes.
public
count() : int
Return values
int —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 —getFlashBag()
Gets the flashbag interface.
public
getFlashBag() : FlashBagInterface
Return values
FlashBagInterface —getId()
Returns the session ID.
public
getId() : string
Return values
string —getIterator()
Returns an iterator for attributes.
public
getIterator() : ArrayIterator<string, mixed>
Return values
ArrayIterator<string, mixed> —getMetadataBag()
Gets session meta.
public
getMetadataBag() : MetadataBag
Return values
MetadataBag —getName()
Returns the session name.
public
getName() : string
Return values
string —getUsageIndex()
public
getUsageIndex() : int
Return values
int —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
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
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
Return values
bool —getAttributeBag()
Gets the attributebag interface.
private
getAttributeBag() : AttributeBagInterface
Note that this method was added to help with IDE autocompletion.