SessionManager implements SessionManagerInterface
Default implementation of SessionManagerInterface.
Tags
Table of Contents
Interfaces
- SessionManagerInterface
- Factory interface for creating session instances.
Properties
- $gcDivisor : int
- $gcProbability : int
- $logger : LoggerInterface
- $store : SessionStoreInterface
Methods
- __construct() : mixed
- create() : SessionInterface
- Creates a new session with an auto-generated UUID.
- createWithId() : SessionInterface
- Creates a session with a specific UUID.
- destroy() : bool
- Destroys the session with the given UUID.
- exists() : bool
- Checks if a session with the given UUID exists.
- gc() : void
- Run garbage collection on expired sessions.
Properties
$gcDivisor read-only
private
int
$gcDivisor
= 100
$gcProbability read-only
private
int
$gcProbability
= 1
$logger read-only
private
LoggerInterface
$logger
= new NullLogger()
$store read-only
private
SessionStoreInterface
$store
Methods
__construct()
public
__construct(SessionStoreInterface $store[, LoggerInterface $logger = new NullLogger() ][, int $gcProbability = 1 ][, int $gcDivisor = 100 ]) : mixed
Parameters
- $store : SessionStoreInterface
- $logger : LoggerInterface = new NullLogger()
- $gcProbability : int = 1
-
The probability (numerator) that GC will run on any given request. Combined with $gcDivisor to calculate the actual probability. Set to 0 to disable GC. Similar to PHP's session.gc_probability.
- $gcDivisor : int = 100
-
The divisor used with $gcProbability to calculate GC probability. The probability is gcProbability/gcDivisor (e.g. 1/100 = 1%). Similar to PHP's session.gc_divisor.
create()
Creates a new session with an auto-generated UUID.
public
create() : SessionInterface
This is the standard factory method for creating sessions.
Return values
SessionInterfacecreateWithId()
Creates a session with a specific UUID.
public
createWithId(Uuid $id) : SessionInterface
Use this when you need to reconstruct a session with a known ID.
Parameters
- $id : Uuid
Return values
SessionInterfacedestroy()
Destroys the session with the given UUID.
public
destroy(Uuid $id) : bool
Parameters
- $id : Uuid
Return values
boolexists()
Checks if a session with the given UUID exists.
public
exists(Uuid $id) : bool
Parameters
- $id : Uuid
Return values
boolgc()
Run garbage collection on expired sessions.
public
gc() : void
Uses the session store's internal TTL configuration.