class SessionManager extends Manager mixin Store

Traits

Constants

DEFAULT_REDIS_CONNECTION

Properties

protected Repository $config

The configuration repository instance.

from  Manager
protected Closure> $customCreators

The registered custom driver creators.

from  Manager
protected array<array-key, mixed> $drivers

The array of created "drivers".

from  Manager

Methods

Closure|null
bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

__construct(Container $container)

Create a new manager instance.

from  Manager
string|null
getDefaultDriver()

Get the default session driver name.

mixed
driver(UnitEnum|string|null $driver = null)

Get a driver instance.

from  Manager
mixed
createDriver(string $driver)

Create a new driver instance.

from  Manager
string|null
getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

from  Manager
mixed
callCustomCreator(string $driver)

Call a custom driver creator.

extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

from  Manager
array
getDrivers()

Get all of the created "drivers".

from  Manager
getContainer()

Get the container instance used by the manager.

from  Manager
setContainer(Container $container)

Set the container instance used by the manager.

from  Manager
forgetDrivers()

Forget all of the resolved driver instances.

from  Manager
mixed
__call(string $method, array $parameters)

Dynamically call the default driver instance.

from  Manager
createNullDriver()

Create an instance of the "null" session driver.

createArrayDriver()

Create an instance of the "array" session driver.

createCookieDriver()

Create an instance of the "cookie" session driver.

createFileDriver()

Create an instance of the file session driver.

createNativeDriver()

Create an instance of the file session driver.

createDatabaseDriver()

Create an instance of the database session driver.

createRedisDriver()

Create an instance of the Redis session driver.

buildSession(SessionHandlerInterface $handler)

Build the session instance.

buildEncryptedSession(SessionHandlerInterface $handler)

Build the encrypted session instance.

bool
supportsUserSessionManagement()

Determine if the configured driver supports user session management.

forUser(Authenticatable|int|string $user, UnitEnum|string|null $guard = null)

Get a user-scoped session repository.

bool
shouldBlock()

Determine if requests for the same session should wait for each to finish before executing.

string|null
blockDriver()

Get the name of the cache store / driver that should be used to acquire session locks.

int
defaultRouteBlockLockSeconds()

Get the maximum number of seconds the session lock should be held for.

int
defaultRouteBlockWaitSeconds()

Get the maximum number of seconds to wait while attempting to acquire a route block session lock.

array
getSessionConfig()

Get the session configuration.

void
setDefaultDriver(UnitEnum|string $name)

Set the default session driver name.

Details

protected Closure|null bindCallbackToSelf(Closure $callback)

Bind the provided callback to the class instance.

Parameters

Closure $callback

Return Value

Closure|null

Exceptions

ReflectionException

in Manager at line 44
__construct(Container $container)

Create a new manager instance.

Parameters

Container $container

at line 286
string|null getDefaultDriver()

Get the default session driver name.

Return Value

string|null

in Manager at line 60
mixed driver(UnitEnum|string|null $driver = null)

Get a driver instance.

Parameters

UnitEnum|string|null $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 92
protected mixed createDriver(string $driver)

Create a new driver instance.

Parameters

string $driver

Return Value

mixed

Exceptions

InvalidArgumentException

in Manager at line 113
protected string|null getCreatorMethod(string $driver)

Get the name of the manager's creator method for the given driver.

Parameters

string $driver

Return Value

string|null

at line 31
protected mixed callCustomCreator(string $driver)

Call a custom driver creator.

Parameters

string $driver

Return Value

mixed

in Manager at line 140
Manager extend(string $driver, Closure $callback)

Register a custom driver creator Closure.

Anonymous closures run in this manager's class scope; non-static closures also receive the manager as $this.

The callback persists in the singleton's customCreators array for the worker lifetime and applies to every subsequent driver resolution.

Parameters

string $driver
Closure $callback

Return Value

Manager

in Manager at line 160
array getDrivers()

Get all of the created "drivers".

Return Value

array

in Manager at line 168
Container getContainer()

Get the container instance used by the manager.

Return Value

Container

in Manager at line 182
Manager setContainer(Container $container)

Set the container instance used by the manager.

Swaps the singleton's container and configuration references; per-request use races across coroutines and breaks every concurrent driver resolution through this manager.

Parameters

Container $container

Return Value

Manager

in Manager at line 199
Manager forgetDrivers()

Forget all of the resolved driver instances.

Clears the singleton's driver cache; concurrent coroutines may already hold references that next resolution will not share.

Return Value

Manager

in Manager at line 210
mixed __call(string $method, array $parameters)

Dynamically call the default driver instance.

Parameters

string $method
array $parameters

Return Value

mixed

at line 39
protected Store createNullDriver()

Create an instance of the "null" session driver.

Return Value

Store

at line 47
protected Store createArrayDriver()

Create an instance of the "array" session driver.

Return Value

Store

at line 57
protected Store createCookieDriver()

Create an instance of the "cookie" session driver.

Return Value

Store

at line 69
protected Store createFileDriver()

Create an instance of the file session driver.

Return Value

Store

at line 77
protected Store createNativeDriver()

Create an instance of the file session driver.

Return Value

Store

at line 91
protected Store createDatabaseDriver()

Create an instance of the database session driver.

Return Value

Store

at line 113
protected Store createRedisDriver()

Create an instance of the Redis session driver.

Return Value

Store

at line 137
protected Store buildSession(SessionHandlerInterface $handler)

Build the session instance.

Parameters

SessionHandlerInterface $handler

Return Value

Store

at line 152
protected EncryptedStore buildEncryptedSession(SessionHandlerInterface $handler)

Build the encrypted session instance.

Parameters

SessionHandlerInterface $handler

Return Value

EncryptedStore

at line 166
bool supportsUserSessionManagement()

Determine if the configured driver supports user session management.

Return Value

bool

at line 179
UserSessions forUser(Authenticatable|int|string $user, UnitEnum|string|null $guard = null)

Get a user-scoped session repository.

Parameters

Authenticatable|int|string $user
UnitEnum|string|null $guard

Return Value

UserSessions

at line 246
bool shouldBlock()

Determine if requests for the same session should wait for each to finish before executing.

Return Value

bool

at line 254
string|null blockDriver()

Get the name of the cache store / driver that should be used to acquire session locks.

Return Value

string|null

at line 262
int defaultRouteBlockLockSeconds()

Get the maximum number of seconds the session lock should be held for.

Return Value

int

at line 270
int defaultRouteBlockWaitSeconds()

Get the maximum number of seconds to wait while attempting to acquire a route block session lock.

Return Value

int

at line 278
array getSessionConfig()

Get the session configuration.

Return Value

array

at line 296
void setDefaultDriver(UnitEnum|string $name)

Set the default session driver name.

Mutates process-global config; per-request use races across coroutines.

Parameters

UnitEnum|string $name

Return Value

void