SymfonyComponentHttpFoundationSessionSessionInterface

Interface for the session.

Methods

start()

start() : Boolean

Starts the session storage.

Throws

RuntimeException

If session fails to start.

Returns

Boolean —

True if session started.

Tags

api

getId()

getId() : string

Returns the session ID.

Returns

string —

The session ID.

Tags

api

setId()

setId(string  $id) 

Sets the session ID

Parameters

string $id

Tags

api

getName()

getName() : mixed

Returns the session name.

Returns

mixed —

The session name.

Tags

api

setName()

setName(string  $name) 

Sets the session name.

Parameters

string $name

Tags

api

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

api

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

api

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

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

api

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

api

set()

set(string  $name, mixed  $value) 

Sets an attribute.

Parameters

string $name
mixed $value

Tags

api

all()

all() : array

Returns attributes.

Returns

array —

Attributes

Tags

api

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

api

clear()

clear() 

Clears all attributes.

Tags

api

isStarted()

isStarted() : Boolean

Checks if the session was started.

Returns

Boolean

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

getMetadataBag()

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

Gets session meta.

Returns

SymfonyComponentHttpFoundationSessionStorageMetadataBag

Tags

None found