interface CookieEnabledInterface implements SessionInterface (View source)

Methods

bool
isStarted()

Tells if the session has been started already.

void
start()

Starts the session, if it has not been already started

bool
canBeResumed()

Returns true if there is a session that can be resumed. false otherwise

int|null
resume()

Resumes an existing session, if any.

string
getId()

Returns the current session ID.

string
renewId()

Generates and propagates a new session ID and transfers all existing data to the new session.

mixed
getData(string $key)

Returns the content (mixed) associated with the given key.

bool
hasKey(string $key)

Returns true if $key is available.

void
putData(string $key, mixed $data)

Stores the given data under the given key in the session

void
addTag(string $tag)

Tags this session with the given tag.

void
removeTag(string $tag)

Removes the specified tag from this session.

array
getTags()

Returns the tags this session has been tagged with.

void
touch()

Updates the last activity time to "now".

int
getLastActivityTimestamp()

Returns the unix time stamp marking the last point in time this session has been in use.

void
close()

Explicitly writes (persists) and closes the session

void
destroy(string|null $reason = null)

Explicitly destroys all session data

getSessionCookie()

No description

static CookieEnabledInterface
createFromCookieAndSessionInformation(Cookie $sessionCookie, string $storageIdentifier, int $lastActivityTimestamp, array $tags = [])

No description

Details

bool isStarted()

Tells if the session has been started already.

Return Value

bool

void start()

Starts the session, if it has not been already started

Return Value

void

bool canBeResumed()

Returns true if there is a session that can be resumed. false otherwise

Return Value

bool

int|null resume()

Resumes an existing session, if any.

Return Value

int|null

If a session was resumed, the inactivity of this session since the last request is returned

string getId()

Returns the current session ID.

Return Value

string

Exceptions

SessionNotStartedException

string renewId()

Generates and propagates a new session ID and transfers all existing data to the new session.

Renewing the session ID is one counter measure against Session Fixation Attacks.

Return Value

string

The new session ID

mixed getData(string $key)

Returns the content (mixed) associated with the given key.

Parameters

string $key

An identifier for the content stored in the session.

Return Value

mixed

The contents associated with the given key

Exceptions

SessionNotStartedException

bool hasKey(string $key)

Returns true if $key is available.

Parameters

string $key

Return Value

bool

void putData(string $key, mixed $data)

Stores the given data under the given key in the session

Parameters

string $key

The key under which the data should be stored

mixed $data

The data to be stored

Return Value

void

Exceptions

SessionNotStartedException

void addTag(string $tag)

Tags this session with the given tag.

Note that third-party libraries might also tag your session. Therefore it is recommended to use namespaced tags such as "Acme-Demo-MySpecialTag".

Parameters

string $tag

The tag – must match be a valid cache frontend tag

Return Value

void

Exceptions

SessionNotStartedException
InvalidArgumentException

void removeTag(string $tag)

Removes the specified tag from this session.

Parameters

string $tag

The tag – must match be a valid cache frontend tag

Return Value

void

Exceptions

SessionNotStartedException

array getTags()

Returns the tags this session has been tagged with.

Return Value

array

The tags or an empty array if there aren't any

Exceptions

SessionNotStartedException

void touch()

Updates the last activity time to "now".

Return Value

void

int getLastActivityTimestamp()

Returns the unix time stamp marking the last point in time this session has been in use.

For the current (local) session, this method will always return the current time. For a remote session, the unix timestamp will be returned.

Return Value

int

unix timestamp

void close()

Explicitly writes (persists) and closes the session

Return Value

void

Exceptions

SessionNotStartedException

void destroy(string|null $reason = null)

Explicitly destroys all session data

Parameters

string|null $reason

A reason for destroying the session – used by the LoggingAspect

Return Value

void

Exceptions

SessionNotStartedException

Cookie getSessionCookie()

No description

Return Value

Cookie

static CookieEnabledInterface createFromCookieAndSessionInformation(Cookie $sessionCookie, string $storageIdentifier, int $lastActivityTimestamp, array $tags = [])

No description

Parameters

Cookie $sessionCookie
string $storageIdentifier
int $lastActivityTimestamp
array $tags

Return Value

CookieEnabledInterface