class DatabaseSessionHandler implements SessionHandlerInterface, ExistenceAwareInterface

Properties

protected ConnectionInterface $connection

The database connection instance.

protected string $table

The name of the session table.

protected int $minutes

The number of minutes the session should be valid.

protected Container $container

The container instance.

protected bool $exists

The existence state of the session.

Methods

void
__construct(ConnectionInterface $connection, string $table, int $minutes, Container $container = null)

Create a new database session handler instance.

open($savePath, $sessionName)

{@inheritdoc}

close()

{@inheritdoc}

read($sessionId)

{@inheritdoc}

bool
expired(stdClass $session)

Determine if the session is expired.

write($sessionId, $data)

{@inheritdoc}

void
performInsert(string $sessionId, string $payload)

Perform an insert operation on the session ID.

int
performUpdate(string $sessionId, string $payload)

Perform an update operation on the session ID.

array
getDefaultPayload(string $data)

Get the default payload for the session.

$this
addUserInformation(array $payload)

Add the user information to the session payload.

mixed
userId()

Get the currently authenticated user's ID.

$this
addRequestInformation(array $payload)

Add the request information to the session payload.

string
ipAddress()

Get the IP address for the current request.

string
userAgent()

Get the user agent for the current request.

destroy($sessionId)

{@inheritdoc}

gc($lifetime)

{@inheritdoc}

getQuery()

Get a fresh query builder instance for the table.

setExists(bool $value)

Set the existence state for the session.

Details

at line 59
void __construct(ConnectionInterface $connection, string $table, int $minutes, Container $container = null)

Create a new database session handler instance.

Parameters

ConnectionInterface $connection
string $table
int $minutes
Container $container

Return Value

void

at line 70
open($savePath, $sessionName)

{@inheritdoc}

Parameters

$savePath
$sessionName

at line 78
close()

{@inheritdoc}

at line 86
read($sessionId)

{@inheritdoc}

Parameters

$sessionId

at line 109
protected bool expired(stdClass $session)

Determine if the session is expired.

Parameters

stdClass $session

Return Value

bool

at line 118
write($sessionId, $data)

{@inheritdoc}

Parameters

$sessionId
$data

at line 142
protected void performInsert(string $sessionId, string $payload)

Perform an insert operation on the session ID.

Parameters

string $sessionId
string $payload

Return Value

void

at line 158
protected int performUpdate(string $sessionId, string $payload)

Perform an update operation on the session ID.

Parameters

string $sessionId
string $payload

Return Value

int

at line 169
protected array getDefaultPayload(string $data)

Get the default payload for the session.

Parameters

string $data

Return Value

array

at line 192
protected $this addUserInformation(array $payload)

Add the user information to the session payload.

Parameters

array $payload

Return Value

$this

at line 206
protected mixed userId()

Get the currently authenticated user's ID.

Return Value

mixed

at line 217
protected $this addRequestInformation(array $payload)

Add the request information to the session payload.

Parameters

array $payload

Return Value

$this

at line 234
protected string ipAddress()

Get the IP address for the current request.

Return Value

string

at line 244
protected string userAgent()

Get the user agent for the current request.

Return Value

string

at line 252
destroy($sessionId)

{@inheritdoc}

Parameters

$sessionId

at line 262
gc($lifetime)

{@inheritdoc}

Parameters

$lifetime

at line 272
protected Builder getQuery()

Get a fresh query builder instance for the table.

Return Value

Builder

at line 283
SessionHandlerInterface setExists(bool $value)

Set the existence state for the session.

Parameters

bool $value

Return Value

SessionHandlerInterface