class WriteSafeSessionHandler implements SessionHandlerInterface, WriteSafeSessionHandlerInterface (View source)

Wraps the session handler to prevent writes when not necessary or allowed.

Properties

protected SessionHandlerInterface $wrappedSessionHandler
protected bool $sessionWritable

Whether or not the session is enabled for writing.

Methods

__construct(SessionHandlerInterface $wrapped_session_handler, bool $session_writable = TRUE)

Constructs a new write safe session handler.

close()

{@inheritdoc}

destroy($session_id)

{@inheritdoc}

gc($max_lifetime)

{@inheritdoc}

open($save_path, $session_id)

{@inheritdoc}

read($session_id)

{@inheritdoc}

write($session_id, $session_data)

{@inheritdoc}

setSessionWritable(bool $flag)

Sets whether or not a session may be written to storage.

bool
isSessionWritable()

Returns whether or not a session may be written to storage.

Details

__construct(SessionHandlerInterface $wrapped_session_handler, bool $session_writable = TRUE)

Constructs a new write safe session handler.

Parameters

SessionHandlerInterface $wrapped_session_handler

The underlying session handler.

bool $session_writable

Whether or not the session should be initially writable.

close()

{@inheritdoc}

destroy($session_id)

{@inheritdoc}

Parameters

$session_id

gc($max_lifetime)

{@inheritdoc}

Parameters

$max_lifetime

open($save_path, $session_id)

{@inheritdoc}

Parameters

$save_path
$session_id

read($session_id)

{@inheritdoc}

Parameters

$session_id

write($session_id, $session_data)

{@inheritdoc}

Parameters

$session_id
$session_data

setSessionWritable(bool $flag)

Sets whether or not a session may be written to storage.

It is not possible to enforce writing of the session data. This method is only capable of forcibly disabling that session data is written to storage.

Parameters

bool $flag

TRUE if the session is allowed to be written, FALSE otherwise.

bool isSessionWritable()

Returns whether or not a session may be written to storage.

Return Value

bool

TRUE if the session is allowed to be written, FALSE otherwise.