CacheSession
in package
implements
SessionHandlerInterface
CacheSession provides method for saving sessions into a Cache engine. Used with Session
Tags
Table of Contents
Interfaces
- SessionHandlerInterface
Properties
- $_options : array<string, mixed>
- Options for this session engine
Methods
- __construct() : mixed
- Constructor.
- close() : bool
- Method called on close of a database session.
- destroy() : bool
- Method called on the destruction of a cache session.
- gc() : int|false
- No-op method. Always returns 0 since cache engine don't have garbage collection.
- open() : bool
- Method called on open of a database session.
- read() : string|false
- Method used to read from a cache session.
- write() : bool
- Helper function called on write for cache sessions.
Properties
$_options
Options for this session engine
protected
array<string, mixed>
$_options
= []
Methods
__construct()
Constructor.
public
__construct([array<string, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string, mixed> = []
-
The configuration to use for this engine It requires the key 'config' which is the name of the Cache config to use for storing the session
Tags
close()
Method called on close of a database session.
public
close() : bool
Return values
bool —Success
destroy()
Method called on the destruction of a cache session.
public
destroy(string $id) : bool
Parameters
- $id : string
-
ID that uniquely identifies session in cache.
Return values
bool —Always true.
gc()
No-op method. Always returns 0 since cache engine don't have garbage collection.
public
gc(int $maxlifetime) : int|false
Parameters
- $maxlifetime : int
-
Sessions that have not updated for the last maxlifetime seconds will be removed.
Attributes
- #[ReturnTypeWillChange]
Return values
int|falseopen()
Method called on open of a database session.
public
open(string $path, string $name) : bool
Parameters
- $path : string
-
The path where to store/retrieve the session.
- $name : string
-
The session name.
Return values
bool —Success
read()
Method used to read from a cache session.
public
read(string $id) : string|false
Parameters
- $id : string
-
ID that uniquely identifies session in cache.
Attributes
- #[ReturnTypeWillChange]
Return values
string|false —Session data or false if it does not exist.
write()
Helper function called on write for cache sessions.
public
write(string $id, string $data) : bool
Parameters
- $id : string
-
ID that uniquely identifies session in cache.
- $data : string
-
The data to be saved.
Return values
bool —True for successful write, false otherwise.