class EncryptedStore extends Store

Traits

Constants

CONTEXT_KEY

The context key used to store the active session for the current request.

STARTED_CONTEXT_KEY_PREFIX

Context key for whether the session has been started.

ATTRIBUTES_CONTEXT_KEY_PREFIX

Context key for the session attributes.

ID_CONTEXT_KEY_PREFIX

Context key for the session ID.

protected READ_ONLY_CONTEXT_KEY_PREFIX

Context key for whether the session is read-only.

protected SUPPORTED_SERIALIZATIONS

The supported session serialization strategies.

protected CSRF_TOKEN_LENGTH

The length of CSRF token strings.

Properties

static protected array $macros

The registered string macros.

from  Macroable
protected string $startedContextKey

The context key for whether this session has been started.

from  Store
protected string $attributesContextKey

The context key for this session's attributes.

from  Store
protected string $idContextKey

The context key for this session's ID.

from  Store
protected string $readOnlyContextKey

The context key for whether this session is read-only.

from  Store
protected Encrypter $encrypter

The encrypter instance.

Methods

static void
macro(string $name, callable|object $macro)

Register a custom macro.

static void
mixin(object $mixin, bool $replace = true)

Mix another object into the class.

static bool
hasMacro(string $name)

Check if macro is registered.

static void
flushMacros()

Flush the existing macros.

static mixed
__callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

mixed
__call(string $method, array $parameters)

Dynamically handle calls to the class.

__construct(string $name, SessionHandlerInterface $handler, Encrypter $encrypter, string|null $id = null, string $serialization = 'php')

Create a new session instance.

bool
start()

Start the session, reading the data from a handler.

from  Store
array
getAttributes()

Get the session attributes.

from  Store
void
setAttributes(array $attributes)

Set the session attributes.

from  Store
void
replaceAttributes(array $attributes)

Replace the session attributes.

from  Store
void
loadSession()

Load the session data from the handler.

from  Store
array
readFromHandler()

Read the session data from the handler.

from  Store
string
prepareForUnserialize(string $data)

Prepare the raw string data from the session for unserialization.

array
marshalErrorBagIn(array $attributes)

Marshal the ViewErrorBag in the given session attributes.

from  Store
void
save()

Save the session data to storage.

from  Store
array
prepareErrorBagForSerialization(array $attributes)

Prepare the ViewErrorBag in the given session attributes for JSON serialization.

from  Store
string
prepareForStorage(string $data)

Prepare the serialized session data for storage.

void
ageFlashData()

Age the flash data for the session.

from  Store
array
ageFlashDataIn(array $attributes)

Age the flash data in the given session attributes.

from  Store
array
all()

Get all of the session data.

from  Store
array
only(array $keys)

Get a subset of the session data.

from  Store
array
except(array $keys)

Get all the session data except for a specified array of items.

from  Store
bool
exists(array|UnitEnum|string $key)

Check if a key exists.

from  Store
bool
missing(array|UnitEnum|string $key)

Determine if the given key is missing from the session data.

from  Store
bool
has(array|UnitEnum|string $key)

Determine if a key is present and not null.

from  Store
bool
hasAny(array|UnitEnum|string $key)

Determine if any of the given keys are present and not null.

from  Store
mixed
get(UnitEnum|string $key, mixed $default = null)

Get an item from the session.

from  Store
mixed
pull(UnitEnum|string $key, mixed $default = null)

Get the value of a given key and then forget it.

from  Store
bool
hasOldInput(UnitEnum|string|null $key = null)

Determine if the session contains old input.

from  Store
mixed
getOldInput(UnitEnum|string|null $key = null, mixed $default = null)

Get the requested item from the flashed input array.

from  Store
void
replace(array $attributes)

Replace the given session attributes entirely.

from  Store
void
put(array|UnitEnum|string $key, mixed $value = null)

Put a key / value pair or array of key / value pairs in the session.

from  Store
mixed
remember(UnitEnum|string $key, Closure $callback)

Get an item from the session, or store the default value.

from  Store
void
push(UnitEnum|string $key, mixed $value)

Push a value onto a session array.

from  Store
int|float
increment(UnitEnum|string $key, int $amount = 1)

Increment the value of an item in the session.

from  Store
int|float
decrement(UnitEnum|string $key, int $amount = 1)

Decrement the value of an item in the session.

from  Store
void
flash(UnitEnum|string $key, mixed $value = true)

Flash a key / value pair to the session.

from  Store
void
now(UnitEnum|string $key, mixed $value)

Flash a key / value pair to the session for immediate use.

from  Store
void
reflash()

Reflash all of the session flash data.

from  Store
void
keep(mixed $keys = null)

Reflash a subset of the current flash data.

from  Store
void
mergeNewFlashes(array $keys)

Merge new flash keys into the new flash array.

from  Store
void
removeFromOldFlashData(array $keys)

Remove the given keys from the old flash data.

from  Store
void
flashInput(array $value)

Flash an input array to the session.

from  Store
cache()

Get the session cache instance.

from  Store
mixed
remove(UnitEnum|string $key)

Remove an item from the session, returning its value.

from  Store
void
forget(array|UnitEnum|string $keys)

Remove one or many items from the session.

from  Store
void
flush()

Remove all of the items from the session.

from  Store
bool
invalidate()

Flush the session data and regenerate the ID.

from  Store
bool
regenerate(bool $destroy = false)

Generate a new session identifier.

from  Store
bool
migrate(bool $destroy = false)

Generate a new session ID for the session.

from  Store
bool
isStarted()

Determine if the session has been started.

from  Store
void
markAsReadOnly()

Mark the session as read-only for the current request.

from  Store
bool
isReadOnly()

Determine if the session is read-only for the current request.

from  Store
string
getName()

Get the name of the session.

from  Store
void
setName(string $name)

Set the name of the session.

from  Store
string
id()

Get the current session ID.

from  Store
string
getId()

Get the current session ID.

from  Store
void
setId(string|null $id)

Set the session ID.

from  Store
bool
isValidId(string|null $id)

Determine if this is a valid session ID.

from  Store
string
generateSessionId()

Get a new, random session ID.

from  Store
void
setExists(bool $value)

Set the existence of the session on the handler if applicable.

from  Store
string|null
token()

Get the CSRF token value.

from  Store
void
regenerateToken()

Regenerate the CSRF token value.

from  Store
bool
hasPreviousUri()

Determine if the previous URI is available.

from  Store
Uri
previousUri()

Get the previous URL from the session as a URI instance.

from  Store
string|null
previousUrl()

Get the previous URL from the session.

from  Store
void
setPreviousUrl(string $url)

Set the "previous" URL in the session.

from  Store
string|null
previousRoute()

Get the previous route name from the session.

from  Store
void
setPreviousRoute(string|null $route)

Set the "previous" route name in the session.

from  Store
void
passwordConfirmed(string|null $guard = null)

Specify that the user has confirmed their password.

from  Store
getHandler()

Get the underlying session handler implementation.

from  Store
setHandler(SessionHandlerInterface $handler)

Set the underlying session handler implementation.

from  Store
bool
handlerNeedsRequest()

Determine if the session handler needs a request.

from  Store
void
setRequestOnHandler(Request $request)

Set the request on the handler instance.

from  Store
static void
flushState()

Flush all static state.

from  Store
getEncrypter()

Get the encrypter instance.

Details

in Macroable at line 30
static void macro(string $name, callable|object $macro)

Register a custom macro.

Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.

Parameters

string $name
callable|object $macro

Return Value

void

in Macroable at line 44
static void mixin(object $mixin, bool $replace = true)

Mix another object into the class.

Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.

Parameters

object $mixin
bool $replace

Return Value

void

Exceptions

ReflectionException

in Macroable at line 61
static bool hasMacro(string $name)

Check if macro is registered.

Parameters

string $name

Return Value

bool

in Macroable at line 72
static void flushMacros()

Flush the existing macros.

Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.

Return Value

void

in Macroable at line 83
static mixed __callStatic(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

in Macroable at line 108
mixed __call(string $method, array $parameters)

Dynamically handle calls to the class.

Parameters

string $method
array $parameters

Return Value

mixed

Exceptions

BadMethodCallException

at line 21
__construct(string $name, SessionHandlerInterface $handler, Encrypter $encrypter, string|null $id = null, string $serialization = 'php')

Create a new session instance.

Parameters

string $name

the session name

SessionHandlerInterface $handler

the session handler implementation

Encrypter $encrypter
string|null $id
string $serialization

the session store's serialization strategy

in Store at line 133
bool start()

Start the session, reading the data from a handler.

Return Value

bool

in Store at line 151
protected array getAttributes()

Get the session attributes.

Return Value

array

in Store at line 159
protected void setAttributes(array $attributes)

Set the session attributes.

Parameters

array $attributes

Return Value

void

in Store at line 167
protected void replaceAttributes(array $attributes)

Replace the session attributes.

Parameters

array $attributes

Return Value

void

in Store at line 178
protected void loadSession()

Load the session data from the handler.

Return Value

void

in Store at line 188
protected array readFromHandler()

Read the session data from the handler.

Return Value

array

at line 31
protected string prepareForUnserialize(string $data)

Prepare the raw string data from the session for unserialization.

Parameters

string $data

Return Value

string

in Store at line 220
protected array marshalErrorBagIn(array $attributes)

Marshal the ViewErrorBag in the given session attributes.

Parameters

array $attributes

Return Value

array

in Store at line 242
void save()

Save the session data to storage.

Return Value

void

in Store at line 273
protected array prepareErrorBagForSerialization(array $attributes)

Prepare the ViewErrorBag in the given session attributes for JSON serialization.

Parameters

array $attributes

Return Value

array

at line 43
protected string prepareForStorage(string $data)

Prepare the serialized session data for storage.

Parameters

string $data

Return Value

string

in Store at line 304
void ageFlashData()

Age the flash data for the session.

Return Value

void

in Store at line 312
protected array ageFlashDataIn(array $attributes)

Age the flash data in the given session attributes.

Parameters

array $attributes

Return Value

array

in Store at line 324
array all()

Get all of the session data.

Return Value

array

in Store at line 332
array only(array $keys)

Get a subset of the session data.

Parameters

array $keys

Return Value

array

in Store at line 340
array except(array $keys)

Get all the session data except for a specified array of items.

Parameters

array $keys

Return Value

array

in Store at line 348
bool exists(array|UnitEnum|string $key)

Check if a key exists.

Parameters

array|UnitEnum|string $key

Return Value

bool

in Store at line 360
bool missing(array|UnitEnum|string $key)

Determine if the given key is missing from the session data.

Parameters

array|UnitEnum|string $key

Return Value

bool

in Store at line 368
bool has(array|UnitEnum|string $key)

Determine if a key is present and not null.

Parameters

array|UnitEnum|string $key

Return Value

bool

in Store at line 378
bool hasAny(array|UnitEnum|string $key)

Determine if any of the given keys are present and not null.

Parameters

array|UnitEnum|string $key

Return Value

bool

in Store at line 388
mixed get(UnitEnum|string $key, mixed $default = null)

Get an item from the session.

Parameters

UnitEnum|string $key
mixed $default

Return Value

mixed

in Store at line 396
mixed pull(UnitEnum|string $key, mixed $default = null)

Get the value of a given key and then forget it.

Parameters

UnitEnum|string $key
mixed $default

Return Value

mixed

in Store at line 409
bool hasOldInput(UnitEnum|string|null $key = null)

Determine if the session contains old input.

Parameters

UnitEnum|string|null $key

Return Value

bool

in Store at line 419
mixed getOldInput(UnitEnum|string|null $key = null, mixed $default = null)

Get the requested item from the flashed input array.

Parameters

UnitEnum|string|null $key
mixed $default

Return Value

mixed

in Store at line 427
void replace(array $attributes)

Replace the given session attributes entirely.

Parameters

array $attributes

Return Value

void

in Store at line 435
void put(array|UnitEnum|string $key, mixed $value = null)

Put a key / value pair or array of key / value pairs in the session.

Parameters

array|UnitEnum|string $key
mixed $value

Return Value

void

in Store at line 452
mixed remember(UnitEnum|string $key, Closure $callback)

Get an item from the session, or store the default value.

Parameters

UnitEnum|string $key
Closure $callback

Return Value

mixed

in Store at line 466
void push(UnitEnum|string $key, mixed $value)

Push a value onto a session array.

Parameters

UnitEnum|string $key
mixed $value

Return Value

void

in Store at line 478
int|float increment(UnitEnum|string $key, int $amount = 1)

Increment the value of an item in the session.

Parameters

UnitEnum|string $key
int $amount

Return Value

int|float

in Store at line 488
int|float decrement(UnitEnum|string $key, int $amount = 1)

Decrement the value of an item in the session.

Parameters

UnitEnum|string $key
int $amount

Return Value

int|float

in Store at line 496
void flash(UnitEnum|string $key, mixed $value = true)

Flash a key / value pair to the session.

Parameters

UnitEnum|string $key
mixed $value

Return Value

void

in Store at line 510
void now(UnitEnum|string $key, mixed $value)

Flash a key / value pair to the session for immediate use.

Parameters

UnitEnum|string $key
mixed $value

Return Value

void

in Store at line 522
void reflash()

Reflash all of the session flash data.

Return Value

void

in Store at line 532
void keep(mixed $keys = null)

Reflash a subset of the current flash data.

Parameters

mixed $keys

Return Value

void

in Store at line 542
protected void mergeNewFlashes(array $keys)

Merge new flash keys into the new flash array.

Parameters

array $keys

Return Value

void

in Store at line 552
protected void removeFromOldFlashData(array $keys)

Remove the given keys from the old flash data.

Parameters

array $keys

Return Value

void

in Store at line 560
void flashInput(array $value)

Flash an input array to the session.

Parameters

array $value

Return Value

void

in Store at line 568
Repository cache()

Get the session cache instance.

Return Value

Repository

in Store at line 576
mixed remove(UnitEnum|string $key)

Remove an item from the session, returning its value.

Parameters

UnitEnum|string $key

Return Value

mixed

in Store at line 589
void forget(array|UnitEnum|string $keys)

Remove one or many items from the session.

Parameters

array|UnitEnum|string $keys

Return Value

void

in Store at line 602
void flush()

Remove all of the items from the session.

Return Value

void

in Store at line 610
bool invalidate()

Flush the session data and regenerate the ID.

Return Value

bool

in Store at line 628
bool regenerate(bool $destroy = false)

Generate a new session identifier.

Parameters

bool $destroy

Return Value

bool

in Store at line 638
bool migrate(bool $destroy = false)

Generate a new session ID for the session.

Parameters

bool $destroy

Return Value

bool

in Store at line 654
bool isStarted()

Determine if the session has been started.

Return Value

bool

in Store at line 666
void markAsReadOnly()

Mark the session as read-only for the current request.

A read-only session is not saved, and regenerating its ID does not destroy the stored session, so the request cannot overwrite session data saved by concurrent requests. Changes made during the request remain available until it ends.

Return Value

void

in Store at line 674
bool isReadOnly()

Determine if the session is read-only for the current request.

Return Value

bool

in Store at line 682
string getName()

Get the name of the session.

Return Value

string

in Store at line 693
void setName(string $name)

Set the name of the session.

Mutates the shared session store name; per-request use races across coroutines and changes the cookie name for concurrent requests.

Parameters

string $name

Return Value

void

in Store at line 702
string id()

Get the current session ID.

Return Value

string

in Store at line 710
string getId()

Get the current session ID.

Return Value

string

in Store at line 726
void setId(string|null $id)

Set the session ID.

Parameters

string|null $id

Return Value

void

in Store at line 737
bool isValidId(string|null $id)

Determine if this is a valid session ID.

Parameters

string|null $id

Return Value

bool

in Store at line 745
protected string generateSessionId()

Get a new, random session ID.

Return Value

string

in Store at line 753
void setExists(bool $value)

Set the existence of the session on the handler if applicable.

Parameters

bool $value

Return Value

void

in Store at line 763
string|null token()

Get the CSRF token value.

Return Value

string|null

in Store at line 771
void regenerateToken()

Regenerate the CSRF token value.

Return Value

void

in Store at line 779
bool hasPreviousUri()

Determine if the previous URI is available.

Return Value

bool

in Store at line 789
Uri previousUri()

Get the previous URL from the session as a URI instance.

Return Value

Uri

Exceptions

RuntimeException

in Store at line 801
string|null previousUrl()

Get the previous URL from the session.

Return Value

string|null

in Store at line 809
void setPreviousUrl(string $url)

Set the "previous" URL in the session.

Parameters

string $url

Return Value

void

in Store at line 817
string|null previousRoute()

Get the previous route name from the session.

Return Value

string|null

in Store at line 825
void setPreviousRoute(string|null $route)

Set the "previous" route name in the session.

Parameters

string|null $route

Return Value

void

in Store at line 836
void passwordConfirmed(string|null $guard = null)

Specify that the user has confirmed their password.

The confirmation is scoped to the given guard, or to the current default guard when none is given.

Parameters

string|null $guard

Return Value

void

in Store at line 857
SessionHandlerInterface getHandler()

Get the underlying session handler implementation.

in Store at line 869
SessionHandlerInterface setHandler(SessionHandlerInterface $handler)

Set the underlying session handler implementation.

Replaces the handler on the shared session store; per-request use races across coroutines and can route session reads or writes through the wrong handler.

Parameters

SessionHandlerInterface $handler

Return Value

SessionHandlerInterface

in Store at line 878
bool handlerNeedsRequest()

Determine if the session handler needs a request.

Return Value

bool

in Store at line 886
void setRequestOnHandler(Request $request)

Set the request on the handler instance.

Parameters

Request $request

Return Value

void

in Store at line 896
static void flushState()

Flush all static state.

Return Value

void

at line 51
Encrypter getEncrypter()

Get the encrypter instance.

Return Value

Encrypter