DatabaseSessionHandler
class DatabaseSessionHandler implements ExistenceAwareInterface, SessionHandlerInterface (View source)
Traits
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
Get the number of seconds until the given DateTime.
If the given value is an interval, convert it to a DateTime instance.
Create a new database session handler instance.
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
{@inheritdoc}
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.
{@inheritdoc}
{@inheritdoc}
Set the existence state for the session.
Details
protected int
secondsUntil(DateTimeInterface|DateInterval|int $delay)
Get the number of seconds until the given DateTime.
protected int
availableAt(DateTimeInterface|DateInterval|int $delay = 0)
Get the "available at" UNIX timestamp.
protected DateTimeInterface|int
parseDateInterval(DateTimeInterface|DateInterval|int $delay)
If the given value is an interval, convert it to a DateTime instance.
protected int
currentTime()
Get the current system time as a UNIX timestamp.
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}
protected bool
expired(stdClass $session)
Determine if the session is expired.
write($sessionId, $data)
{@inheritdoc}
protected bool|null
performInsert(string $sessionId, string $payload)
Perform an insert operation on the session ID.
protected int
performUpdate(string $sessionId, string $payload)
Perform an update operation on the session ID.
protected array
getDefaultPayload(string $data)
Get the default payload for the session.
protected $this
addUserInformation(array $payload)
Add the user information to the session payload.
protected mixed
userId()
Get the currently authenticated user's ID.
protected $this
addRequestInformation(array $payload)
Add the request information to the session payload.
protected string
ipAddress()
Get the IP address for the current request.
protected string
userAgent()
Get the user agent for the current request.
destroy($sessionId)
{@inheritdoc}
gc($lifetime)
{@inheritdoc}
protected Builder
getQuery()
Get a fresh query builder instance for the table.
SessionHandlerInterface
setExists(bool $value)
Set the existence state for the session.