CookieStore
in package
implements
StoreInterface
Class CookieStore.
This class provides a layer to persist transient auth data using cookies.
Interfaces, Classes, Traits and Enums
- StoreInterface
- Interface StoreInterface.
Table of Contents
- KEY_CHUNKING_THRESHOLD = 2048
- KEY_HASHING_ALGO = 'sha256'
- KEY_SEPARATOR = '_'
- VAL_CRYPTO_ALGO = 'aes-128-gcm'
- $configuration : SdkConfiguration
- $deferring : bool
- When true, CookieStore will not setState() itself. You will need manually call the method to persist state to storage.
- $dirty : bool
- Determine if changes have been made since the last setState.
- $encrypt : bool
- Determine if changes have been made since the last setState.
- $namespace : string
- $store : array<string|int, mixed>
- Internal cache of the storage state.
- __construct() : mixed
- CookieStore constructor.
- decrypt() : array<string|int, mixed>|null
- Decrypt data from a stored cookie string.
- defer() : void
- Defer saving state changes to destination to improve performance during blocks of changes.
- delete() : void
- Removes a persisted value identified by $key.
- encrypt() : string
- Encrypt data for safe storage format for a cookie.
- get() : mixed
- Gets persisted values identified by $key.
- getCookieOptions() : array<string|int, mixed>
- Build options array for use with setcookie().
- getEncrypted() : bool
- Returns the current encryption state.
- getNamespace() : string
- Returns the current namespace identifier.
- getState() : array<string|int, mixed>
- Setup our storage state by pulling from persistence source.
- purge() : void
- Removes all persisted values.
- set() : void
- Persists $value on cookies, identified by $key.
- setEncrypted() : self
- Toggle the encryption state.
- setState() : self
- Push our storage state to the source for persistence.
Constants
KEY_CHUNKING_THRESHOLD
public
mixed
KEY_CHUNKING_THRESHOLD
= 2048
KEY_HASHING_ALGO
public
mixed
KEY_HASHING_ALGO
= 'sha256'
KEY_SEPARATOR
public
mixed
KEY_SEPARATOR
= '_'
VAL_CRYPTO_ALGO
public
mixed
VAL_CRYPTO_ALGO
= 'aes-128-gcm'
Properties
$configuration
private
SdkConfiguration
$configuration
$deferring
When true, CookieStore will not setState() itself. You will need manually call the method to persist state to storage.
private
bool
$deferring
= false
$dirty
Determine if changes have been made since the last setState.
private
bool
$dirty
= false
$encrypt
Determine if changes have been made since the last setState.
private
bool
$encrypt
= true
$namespace
private
string
$namespace
= 'auth0'
$store
Internal cache of the storage state.
private
array<string|int, mixed>
$store
= []
Methods
__construct()
CookieStore constructor.
public
__construct(SdkConfiguration $configuration[, string $namespace = 'auth0' ]) : mixed
Parameters
- $configuration : SdkConfiguration
-
Base configuration options for the SDK. See the SdkConfiguration class constructor for options.
- $namespace : string = 'auth0'
-
a string in which to store cookies under on devices
Tags
Return values
mixed —decrypt()
Decrypt data from a stored cookie string.
public
decrypt(string $data) : array<string|int, mixed>|null
Parameters
- $data : string
-
string representing an encrypted data structure
Tags
Return values
array<string|int, mixed>|null —defer()
Defer saving state changes to destination to improve performance during blocks of changes.
public
defer(bool $deferring) : void
Parameters
- $deferring : bool
-
whether to defer persisting the storage state
Return values
void —delete()
Removes a persisted value identified by $key.
public
delete(string $key) : void
Parameters
- $key : string
-
cookie to delete
Return values
void —encrypt()
Encrypt data for safe storage format for a cookie.
public
encrypt(array<string|int, mixed> $data[, array<string|int, mixed> $options = [] ]) : string
Parameters
- $data : array<string|int, mixed>
-
data to encrypt
- $options : array<string|int, mixed> = []
-
additional configuration options
Tags
Return values
string —get()
Gets persisted values identified by $key.
public
get(string $key[, mixed $default = null ]) : mixed
If the value is not set, returns $default.
Parameters
- $key : string
-
cookie to set
- $default : mixed = null
-
default to return if nothing was found
Return values
mixed —getCookieOptions()
Build options array for use with setcookie().
public
getCookieOptions([int|null $expires = null ]) : array<string|int, mixed>
Parameters
- $expires : int|null = null
Return values
array<string|int, mixed> —getEncrypted()
Returns the current encryption state.
public
getEncrypted() : bool
Return values
bool —getNamespace()
Returns the current namespace identifier.
public
getNamespace() : string
Return values
string —getState()
Setup our storage state by pulling from persistence source.
public
getState([array<string|int, mixed> $state = null ]) : array<string|int, mixed>
Parameters
- $state : array<string|int, mixed> = null
-
skip loading any persistent source state and inject a custom state
Return values
array<string|int, mixed> —purge()
Removes all persisted values.
public
purge() : void
Return values
void —set()
Persists $value on cookies, identified by $key.
public
set(string $key, mixed $value) : void
Parameters
- $key : string
-
cookie to set
- $value : mixed
-
value to use
Return values
void —setEncrypted()
Toggle the encryption state.
public
setEncrypted([bool $encrypt = true ]) : self
Parameters
- $encrypt : bool = true
-
enable or disable cookie encryption
Return values
self —setState()
Push our storage state to the source for persistence.
public
setState([bool $force = false ]) : self
Parameters
- $force : bool = false