Properties

$storage

$storage : 

Type

$flashName

$flashName : 

Type

$attributeName

$attributeName : 

Type

$data

$data : 

Type

$usageIndex

$usageIndex : 

Type

Methods

__construct()

__construct(\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface  $storage = null, \Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface  $attributes = null, \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface  $flashes = null) 

Parameters

\Symfony\Component\HttpFoundation\Session\Storage\SessionStorageInterface $storage

A SessionStorageInterface instance

\Symfony\Component\HttpFoundation\Session\Attribute\AttributeBagInterface $attributes

An AttributeBagInterface instance, (defaults null for default AttributeBag)

\Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface $flashes

A FlashBagInterface instance (defaults null for default FlashBag)

start()

start() : boolean

Starts the session storage.

Returns

boolean —

True if session started

has()

has(string  $name) : boolean

Checks if an attribute is defined.

Parameters

string $name

The attribute name

Returns

boolean —

true if the attribute is defined, false otherwise

get()

get(string  $name, mixed  $default = null) : mixed

Returns an attribute.

Parameters

string $name

The attribute name

mixed $default

The default value if not found

Returns

mixed

set()

set(string  $name, mixed  $value) 

Sets an attribute.

Parameters

string $name
mixed $value

all()

all() : array

Returns attributes.

Returns

array —

Attributes

replace()

replace(array  $attributes) 

Sets attributes.

Parameters

array $attributes

Attributes

remove()

remove(string  $name) : mixed

Removes an attribute.

Parameters

string $name

Returns

mixed —

The removed value or null when it does not exist

clear()

clear() 

Clears all attributes.

isStarted()

isStarted() : boolean

Checks if the session was started.

Returns

boolean

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for attributes.

Returns

\ArrayIterator —

An \ArrayIterator instance

count()

count() : integer

Returns the number of attributes.

Returns

integer —

The number of attributes

invalidate()

invalidate(integer  $lifetime = null) : boolean

Invalidates the current session.

Clears all session attributes and flashes and regenerates the session and deletes the old session from persistence.

Parameters

integer $lifetime

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.

Returns

boolean —

True if session invalidated, false if error

migrate()

migrate(boolean  $destroy = false, integer  $lifetime = null) : boolean

Migrates the current session to a new session id while maintaining all session attributes.

Parameters

boolean $destroy

Whether to delete the old session or leave it to garbage collection

integer $lifetime

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.

Returns

boolean —

True if session migrated, false if error

save()

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.

getId()

getId() : string

Returns the session ID.

Returns

string —

The session ID

setId()

setId(string  $id) 

Sets the session ID.

Parameters

string $id

getName()

getName() : mixed

Returns the session name.

Returns

mixed —

The session name

setName()

setName(string  $name) 

Sets the session name.

Parameters

string $name