interface SessionManagerInterface (View source)

Interface for a session manager

In order to stay compatible with future features and create more portable apps, make sure to inject this interface instead of the concrete SessionManager implementation.

Methods

getCurrentSession()

Returns the currently active session which stores session data for the current HTTP request on this local system.

getSession(string $sessionIdentifier)

Returns the specified session. If no session with the given identifier exists, NULL is returned.

getActiveSessions()

Returns all active sessions, even remote ones.

array
getSessionsByTag(string $tag)

Returns all sessions which are tagged by the specified tag.

int
destroySessionsByTag(string $tag, string $reason = '')

Destroys all sessions which are tagged with the specified tag.

Details

SessionInterface getCurrentSession()

Returns the currently active session which stores session data for the current HTTP request on this local system.

Return Value

SessionInterface

SessionInterface getSession(string $sessionIdentifier)

Returns the specified session. If no session with the given identifier exists, NULL is returned.

Parameters

string $sessionIdentifier

The session identifier

Return Value

SessionInterface

Session[] getActiveSessions()

Returns all active sessions, even remote ones.

Return Value

Session[]

array getSessionsByTag(string $tag)

Returns all sessions which are tagged by the specified tag.

Parameters

string $tag

A valid Cache Frontend tag

Return Value

array

A collection of Session objects or an empty array if tag did not match

int destroySessionsByTag(string $tag, string $reason = '')

Destroys all sessions which are tagged with the specified tag.

Parameters

string $tag

A valid Cache Frontend tag

string $reason

A reason to mention in log output for why the sessions have been destroyed. For example: "The corresponding account was deleted"

Return Value

int

Number of sessions which have been destroyed