DatabaseSessionHandler
class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerInterface
Traits
Constants
| protected DATABASE_EXISTS_CONTEXT_KEY_PREFIX |
Context key prefix for whether the session record exists in the database. Suffixed with the handler's object ID so multiple handler instances within the same coroutine maintain independent existence state. |
Methods
Get the number of seconds until the given DateTime.
Get the "available at" UNIX timestamp.
If the given value is an interval, convert it to a DateTime instance.
Given a start time, format the total run time for human readability.
Create a new database session handler instance.
No description
No description
No description
Determine if the session is expired.
No description
Perform an insert operation on the session ID.
Perform an update operation on the session ID.
Get the default payload for the session.
Add the user information to the session payload.
Get the currently authenticated user's ID.
Add the request information to the session payload.
Get the IP address for the current request.
Get the user agent for the current request.
No description
No description
Get the underlying database connection.
Set the existence state for the session.
Get the existence state for the session.
Reset this handler's existence state when it is cloned.
Details
in
InteractsWithTime at line 17
protected int
secondsUntil(DateInterval|DateTimeInterface|int $delay)
Get the number of seconds until the given DateTime.
in
InteractsWithTime at line 29
protected int
availableAt(DateInterval|DateTimeInterface|int|null $delay = 0)
Get the "available at" UNIX timestamp.
in
InteractsWithTime at line 41
protected DateTimeInterface|int
parseDateInterval(DateInterval|DateTimeInterface|int|null $delay)
If the given value is an interval, convert it to a DateTime instance.
in
InteractsWithTime at line 57
protected int
currentTime()
Get the current system time as a UNIX timestamp.
in
InteractsWithTime at line 65
protected string
runTimeForHumans(float $startTime, float|null $endTime = null)
Given a start time, format the total run time for human readability.
at line 40
__construct(ConnectionResolverInterface $resolver, string|null $connection, string $table, int $minutes, Container|null $container = null)
Create a new database session handler instance.
at line 50
bool
open(string $savePath, string $sessionName)
No description
at line 55
bool
close()
No description
at line 60
false|string
read(string $sessionId)
No description
at line 82
protected bool
expired(object $session)
Determine if the session is expired.
at line 88
bool
write(string $sessionId, string $data)
No description
at line 115
protected bool|null
performInsert(string $sessionId, array $payload)
Perform an insert operation on the session ID.
at line 131
protected int
performUpdate(string $sessionId, array $payload)
Perform an update operation on the session ID.
at line 139
protected array
getDefaultPayload(string $data)
Get the default payload for the session.
at line 159
protected DatabaseSessionHandler
addUserInformation(array $payload)
Add the user information to the session payload.
at line 171
protected mixed
userId()
Get the currently authenticated user's ID.
at line 179
protected DatabaseSessionHandler
addRequestInformation(array $payload)
Add the request information to the session payload.
at line 194
protected string|null
ipAddress()
Get the IP address for the current request.
at line 202
protected string
userAgent()
Get the user agent for the current request.
at line 207
bool
destroy(string $sessionId)
No description
at line 214
int
gc(int $lifetime)
No description
at line 222
protected Builder
getQuery()
Get a fresh query builder instance for the table.
at line 230
ConnectionInterface
connection()
Get the underlying database connection.
at line 242
DatabaseSessionHandler
setContainer(Container $container)
Set the application instance used by the handler.
Boot or tests only. Mutating the container on a shared handler during request handling can expose the wrong request or authentication state to concurrent coroutines.
at line 252
SessionHandlerInterface
setExists(bool $value)
Set the existence state for the session.
at line 262
bool
getExists()
Get the existence state for the session.
at line 273
void
__clone()
Reset this handler's existence state when it is cloned.
PHP reuses freed object IDs, so a clone can land on a released handler's ID and must not inherit its existence state.