\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() : bool

Starts the session storage.

Throws

\RuntimeException

if session fails to start

Returns

bool —

getId()

getId() : string

Returns the session ID.

Returns

string —

setId()

setId(string  $id) : mixed

Sets the session ID.

Parameters

string $id

Returns

mixed —

getName()

getName() : string

Returns the session name.

Returns

string —

setName()

setName(string  $name) : mixed

Sets the session name.

Parameters

string $name

Returns

mixed —

invalidate()

invalidate(int|null  $lifetime = null) : bool

Invalidates the current session.

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

Parameters

int|null $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

bool —

migrate()

migrate(bool  $destroy = false, int|null  $lifetime = null) : bool

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

Parameters

bool $destroy

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

int|null $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

bool —

save()

save() : mixed

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.

Returns

mixed —

has()

has(string  $name) : bool

Checks if an attribute is defined.

Parameters

string $name

Returns

bool —

get()

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

Returns an attribute.

Parameters

string $name
mixed $default

The default value if not found

Returns

mixed —

set()

set(string  $name, mixed  $value) : mixed

Sets an attribute.

Parameters

string $name
mixed $value

Returns

mixed —

all()

all() : array

Returns attributes.

Returns

array —

replace()

replace(array  $attributes) : mixed

Sets attributes.

Parameters

array $attributes

Returns

mixed —

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() : mixed

Clears all attributes.

Returns

mixed —

isStarted()

isStarted() : bool

Checks if the session was started.

Returns

bool —

registerBag()

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

Registers a SessionBagInterface with the session.

Parameters

\Symfony\Component\HttpFoundation\Session\SessionBagInterface $bag

Returns

mixed —

getBag()

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

Gets a bag instance by name.

Parameters

string $name

Returns

\Symfony\Component\HttpFoundation\Session\SessionBagInterface —

getMetadataBag()

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

Gets session meta.

Returns

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