RedisSessionHandler
in package
implements
SessionHandlerInterface
This class will manage the Redis sessions.
Tags
Interfaces, Classes and Traits
- SessionHandlerInterface
Table of Contents
$ttl | Variable that sets the session ttl. | : int |
---|---|---|
$db | : Client|null | |
$prefix | : string | |
__construct() | Sets a header with the given key and value. | : mixed |
close() | Close the connection with the Redis client. | : bool |
destroy() | Destroy a session | : bool |
gc() | Unused method when managing sessions with Redis | : int |
open() | Unused method when managing sessions with Redis | : bool |
read() | Read session data | : string |
write() | Write session data | : bool |
Properties
$ttl
Variable that sets the session ttl.
public
int
$ttl
= 7500
$db
protected
Client|null
$db
$prefix
protected
string
$prefix
Methods
__construct()
Sets a header with the given key and value.
public
__construct([Client $db = null ][, string $prefix = 'COMMERCE_' ]) : mixed
Parameters
- $db : Client = null
-
The PRedis Client we're going to use on this session
- $prefix : string = 'COMMERCE_'
-
The prefix to use on the keys of the current session
Return values
mixed —close()
Close the connection with the Redis client.
public
close() : bool
Return values
bool —destroy()
Destroy a session
public
destroy(string $id) : bool
Parameters
- $id : string
-
The session ID being destroyed.
Return values
bool —gc()
Unused method when managing sessions with Redis
public
gc(mixed $maxLifetime) : int
Parameters
- $maxLifetime : mixed
Return values
int —open()
Unused method when managing sessions with Redis
public
open(mixed $savePath, mixed $sessionName) : bool
Parameters
- $savePath : mixed
- $sessionName : mixed
Return values
bool —read()
Read session data
public
read(string $id) : string
Parameters
- $id : string
-
The session id.
Return values
string —write()
Write session data
public
write(string $id, string $data) : bool
Parameters
- $id : string
-
The session id.
- $data : string
-
The encoded session data. This data is the result of the PHP internally encoding the $_SESSION superglobal to a serialized string and passing it as this parameter. Please note sessions use an alternative serialization method.