class TransientSession implements SessionInterface (View source)

Implementation of a transient session.

This session behaves like any other session except that it only stores the data during one request.

Properties

protected $sessionId
protected $started
protected $data
protected $lastActivityTimestamp
protected $tags

Methods

bool
isStarted()

Tells if the session has been started already.

void
start()

No description

bool
canBeResumed()

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

int|null
resume()

No description

string
renewId()

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

string
getId()

Returns the current session ID.

mixed
getData(string $key)

Returns the data 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
close()

Closes the session

void
destroy(string|null $reason = null)

Explicitly destroys all session data

int
getLastActivityTimestamp()

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

void
touch()

Updates the last activity time to "now".

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.

Details

bool isStarted()

Tells if the session has been started already.

Return Value

bool

void start()

No description

Return Value

void

Exceptions

Exception

bool canBeResumed()

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

Return Value

bool

int|null resume()

No description

Return Value

int|null

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

Exceptions

Exception

string renewId()

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

Return Value

string

The new session ID

Exceptions

Exception

string getId()

Returns the current session ID.

Return Value

string

Exceptions

SessionNotStartedException

mixed getData(string $key)

Returns the data 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 close()

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

int getLastActivityTimestamp()

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

Return Value

int

unix timestamp

void touch()

Updates the last activity time to "now".

Return Value

void

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