joomla/session
Framework-agnostic PHP 8.1+ session management from the Joomla Framework. Provides interfaces and utilities to start and manage sessions, store and retrieve session data, and integrate session handling cleanly within your application.
The SessionInterface defines an class which manages session data in a web application. This interface is an extension of PHP's IteratorAggregate interface and implementations must comply with the iterator's requirements as well.
Functionally, this interface is a wrapper around Joomla\Session\StorageInterface and many of the methods are inherently similar, please see the documentation for the StorageInterface for more details about the noted methods.
getName()setName()getId()getId()isActive()isStarted()get()set()has()remove()clear()all()close()gc()abort()The getExpire() method is used to get the session lifetime in seconds.
/**
* [@return](https://github.com/return) integer The session expiration time in seconds
*/
public function getExpire();
The is() method is used to determine if a session is new (generally, this is true if the session was created in the current request).
/**
* [@return](https://github.com/return) boolean
*/
public function isNew();
The getToken() method is used to fetch the current session token. This token is generally used in conjunction with CSRF related checks.
/**
* [@param](https://github.com/param) boolean $forceNew If true, forces a new token to be created
*
* [@return](https://github.com/return) string
*
* [@since](https://github.com/since) __DEPLOY_VERSION__
*/
public function getToken($forceNew = false);
The hasToken() method is used to determine if the current session token matches the specified token.
/**
* Check if the session has the given token.
*
* [@param](https://github.com/param) string $token Hashed token to be verified
* [@param](https://github.com/param) boolean $forceExpire If true, expires the session
*
* [@return](https://github.com/return) boolean
*
* [@since](https://github.com/since) __DEPLOY_VERSION__
*/
public function hasToken($token, $forceExpire = true);
The start() method is used to start the session. Generally, this includes calling the StorageInterface::start() method, validating the current session against potential attacks, configuring any session related internal behaviors, and optionally dispatching events to subscribers.
/**
* [@return](https://github.com/return) void
*/
public function start();
The start() method is used to start the session. Generally, this includes calling the StorageInterface::start() method, validating the current session against potential attacks, configuring any session related internal behaviors, and optionally dispatching events to subscribers.
/**
* [@return](https://github.com/return) boolean
*/
public function destroy();
The restart() method is used to restart an expired or locked session. Generally, this includes calling the StorageInterface::start() method, validating the current session against potential attacks, configuring any session related internal behaviors, and optionally dispatching events to subscribers.
/**
* [@return](https://github.com/return) void
*/
public function restart();
The fork() method is used to generate a new session with the existing data.
An example use of this method is to migrate the session data to a new session (with a new ID) after a user authenticates with your application.
/**
* [@return](https://github.com/return) boolean
*/
public function fork();
How can I help you explore Laravel packages today?