Properties

$storage

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

Storage driver.

Type

SymfonyComponentHttpFoundationSessionStorageSessionStorageInterface

Tags

None found

$flashName

$flashName : string

Type

string

Tags

None found

$attributeName

$attributeName : string

Type

string

Tags

None found

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) 

Constructor.

Parameters

SymfonyComponentHttpFoundationSessionStorageSessionStorageInterface $storage

A SessionStorageInterface instance.

SymfonyComponentHttpFoundationSessionAttributeAttributeBagInterface $attributes

An AttributeBagInterface instance, (defaults null for default AttributeBag)

SymfonyComponentHttpFoundationSessionFlashFlashBagInterface $flashes

A FlashBagInterface instance (defaults null for default FlashBag)

Tags

None found

start()

start() : Boolean

Starts the session storage.

Returns

Boolean —

True if session started.

Tags

None found

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

Tags

None found

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

Tags

None found

set()

set(string  $name, mixed  $value) 

Sets an attribute.

Parameters

string $name
mixed $value

Tags

None found

all()

all() : array

Returns attributes.

Returns

array —

Attributes

Tags

None found

replace()

replace(array  $attributes) 

Sets attributes.

Parameters

array $attributes

Attributes

Tags

None found

remove()

remove(string  $name) : mixed

Removes an attribute.

Parameters

string $name

Returns

mixed —

The removed value

Tags

None found

clear()

clear() 

Clears all attributes.

Tags

None found

isStarted()

isStarted() : Boolean

Checks if the session was started.

Returns

Boolean

Tags

None found

getIterator()

getIterator() : \ArrayIterator

Returns an iterator for attributes.

Returns

ArrayIterator —

An ArrayIterator instance

Tags

None found

count()

count() : integer

Returns the number of attributes.

Returns

integer —

The number of attributes

Tags

None found

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.

Tags

None found

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.

Tags

None found

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.

Tags

None found

getId()

getId() : string

Returns the session ID.

Returns

string —

The session ID.

Tags

None found

setId()

setId(string  $id) 

Sets the session ID

Parameters

string $id

Tags

None found

getName()

getName() : mixed

Returns the session name.

Returns

mixed —

The session name.

Tags

None found

setName()

setName(string  $name) 

Sets the session name.

Parameters

string $name

Tags

None found

getMetadataBag()

getMetadataBag() : \Symfony\Component\HttpFoundation\Session\Storage\MetadataBag

Gets session meta.

Returns

SymfonyComponentHttpFoundationSessionStorageMetadataBag

Tags

None found

registerBag()

registerBag(\Symfony\Component\HttpFoundation\Session\SessionBagInterface  $bag) 

Registers a SessionBagInterface with the session.

Parameters

SymfonyComponentHttpFoundationSessionSessionBagInterface $bag

Tags

None found

getBag()

getBag(string  $name) : \Symfony\Component\HttpFoundation\Session\SessionBagInterface

Gets a bag instance by name.

Parameters

string $name

Returns

SymfonyComponentHttpFoundationSessionSessionBagInterface

Tags

None found

getFlashBag()

getFlashBag() : \Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface

Gets the flashbag interface.

Returns

SymfonyComponentHttpFoundationSessionFlashFlashBagInterface

Tags

None found

getFlashes()

getFlashes() : array

Returns

array

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

setFlashes()

setFlashes(array  $values) 

Parameters

array $values

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

getFlash()

getFlash(string  $name, string  $default = null) : string

Parameters

string $name
string $default

Returns

string

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

setFlash()

setFlash(string  $name, string  $value) 

Parameters

string $name
string $value

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

hasFlash()

hasFlash(string  $name) : Boolean

Parameters

string $name

Returns

Boolean

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

removeFlash()

removeFlash(string  $name) 

Parameters

string $name

Deprecated

since 2.1, will be removed from 2.3

Tags

None found

clearFlashes()

clearFlashes() : array

Returns

array

Deprecated

since 2.1, will be removed from 2.3

Tags

None found