NativeSessionTokenStorage
in package
implements
ClearableTokenStorageInterface
Token storage that uses PHP's native session handling.
Tags
Table of Contents
Interfaces
- ClearableTokenStorageInterface
- Stores CSRF tokens.
Constants
- SESSION_NAMESPACE = '_csrf'
- The namespace used to store values in the session.
Properties
- $namespace : string
- $sessionStarted : bool
Methods
- __construct() : mixed
- Initializes the storage with a session namespace.
- clear() : mixed
- Removes all CSRF tokens.
- getToken() : string
- {@inheritdoc}
- hasToken() : bool
- {@inheritdoc}
- removeToken() : string|null
- {@inheritdoc}
- setToken() : mixed
- {@inheritdoc}
- startSession() : mixed
Constants
SESSION_NAMESPACE
The namespace used to store values in the session.
public
mixed
SESSION_NAMESPACE
= '_csrf'
Properties
$namespace
private
string
$namespace
$sessionStarted
private
bool
$sessionStarted
= false
Methods
__construct()
Initializes the storage with a session namespace.
public
__construct([string $namespace = self::SESSION_NAMESPACE ]) : mixed
Parameters
- $namespace : string = self::SESSION_NAMESPACE
-
The namespace under which the token is stored in the session
clear()
Removes all CSRF tokens.
public
clear() : mixed
getToken()
{@inheritdoc}
public
getToken(string $tokenId) : string
Parameters
- $tokenId : string
Return values
stringhasToken()
{@inheritdoc}
public
hasToken(string $tokenId) : bool
Parameters
- $tokenId : string
Return values
boolremoveToken()
{@inheritdoc}
public
removeToken(string $tokenId) : string|null
Parameters
- $tokenId : string
Return values
string|nullsetToken()
{@inheritdoc}
public
setToken(string $tokenId, string $token) : mixed
Parameters
- $tokenId : string
- $token : string
startSession()
private
startSession() : mixed