\Symfony\Component\HttpFoundation\SessionSessionInterface

Interface for the session.

Summary

Methods
Constants
start()
getId()
setId()
getName()
setName()
invalidate()
migrate()
save()
has()
get()
set()
all()
replace()
remove()
clear()
isStarted()
registerBag()
getBag()
getMetadataBag()
No constants found
No protected methods found
N/A
No private methods found
N/A

Methods

start()

start() : boolean

Starts the session storage.

Throws

\RuntimeException

if session fails to start

Returns

boolean

getId()

getId() : string

Returns the session ID.

Returns

string

setId()

setId(\Symfony\Component\HttpFoundation\Session\string  $id) 

Sets the session ID.

Parameters

\Symfony\Component\HttpFoundation\Session\string $id

getName()

getName() : string

Returns the session name.

Returns

string

setName()

setName(\Symfony\Component\HttpFoundation\Session\string  $name) 

Sets the session name.

Parameters

\Symfony\Component\HttpFoundation\Session\string $name

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

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

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.

has()

has(\Symfony\Component\HttpFoundation\Session\string  $name) : boolean

Checks if an attribute is defined.

Parameters

\Symfony\Component\HttpFoundation\Session\string $name

Returns

boolean

get()

get(\Symfony\Component\HttpFoundation\Session\string  $name, mixed  $default = null) : mixed

Returns an attribute.

Parameters

\Symfony\Component\HttpFoundation\Session\string $name
mixed $default

The default value if not found

Returns

mixed

set()

set(\Symfony\Component\HttpFoundation\Session\string  $name, mixed  $value) 

Sets an attribute.

Parameters

\Symfony\Component\HttpFoundation\Session\string $name
mixed $value

all()

all() : array

Returns attributes.

Returns

array

replace()

replace(array  $attributes) 

Sets attributes.

Parameters

array $attributes

remove()

remove(\Symfony\Component\HttpFoundation\Session\string  $name) : mixed

Removes an attribute.

Parameters

\Symfony\Component\HttpFoundation\Session\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

getMetadataBag()

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

Gets session meta.

Returns

\Symfony\Component\HttpFoundation\Session\Storage\MetadataBag