Store
class Store implements Session
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 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. |
|
| protected string | $attributesContextKey | The context key for this session's attributes. |
|
| protected string | $idContextKey | The context key for this session's ID. |
Methods
Mix another object into the class.
Dynamically handle calls to the class.
Dynamically handle calls to the class.
Create a new session instance.
Start the session, reading the data from a handler.
Get the session attributes.
Set the session attributes.
Replace the session attributes.
Load the session data from the handler.
Read the session data from the handler.
Prepare the raw string data from the session for unserialization.
Marshal the ViewErrorBag in the given session attributes.
Save the session data to storage.
Prepare the ViewErrorBag in the given session attributes for JSON serialization.
Prepare the serialized session data for storage.
Age the flash data for the session.
Age the flash data in the given session attributes.
Get all of the session data.
Get a subset of the session data.
Get all the session data except for a specified array of items.
Check if a key exists.
Determine if the given key is missing from the session data.
Determine if a key is present and not null.
Determine if any of the given keys are present and not null.
Get an item from the session.
Get the value of a given key and then forget it.
Determine if the session contains old input.
Get the requested item from the flashed input array.
Replace the given session attributes entirely.
Put a key / value pair or array of key / value pairs in the session.
Push a value onto a session array.
Increment the value of an item in the session.
Decrement the value of an item in the session.
Flash a key / value pair to the session.
Flash a key / value pair to the session for immediate use.
Reflash all of the session flash data.
Reflash a subset of the current flash data.
Merge new flash keys into the new flash array.
Remove the given keys from the old flash data.
Flash an input array to the session.
Get the session cache instance.
Remove an item from the session, returning its value.
Remove one or many items from the session.
Remove all of the items from the session.
Flush the session data and regenerate the ID.
Generate a new session identifier.
Generate a new session ID for the session.
Determine if the session has been started.
Get the name of the session.
Set the name of the session.
Get the current session ID.
Get the current session ID.
Set the session ID.
Determine if this is a valid session ID.
Get a new, random session ID.
Set the existence of the session on the handler if applicable.
Get the CSRF token value.
Regenerate the CSRF token value.
Determine if the previous URI is available.
Get the previous URL from the session as a URI instance.
Get the previous URL from the session.
Set the "previous" URL in the session.
Get the previous route name from the session.
Set the "previous" route name in the session.
Specify that the user has confirmed their password.
Get the underlying session handler implementation.
Determine if the session handler needs a request.
Flush all static state.
Details
in
Macroable at line 28
static void
macro(string $name, callable|object $macro)
Register a custom macro.
Boot-only. Macros persist in a static property for the worker lifetime and apply to every subsequent call on the macroable class.
in
Macroable at line 41
static void
mixin(object $mixin, bool $replace = true)
Mix another object into the class.
Boot-only. Delegates to macro() for each method; registered macros persist in a static property for the worker lifetime.
in
Macroable at line 57
static bool
hasMacro(string $name)
Check if macro is registered.
in
Macroable at line 68
static void
flushMacros()
Flush the existing macros.
Boot or tests only. Clears worker-wide macros; concurrent coroutines may resolve different methods depending on timing.
in
Macroable at line 78
static mixed
__callStatic(string $method, array $parameters)
Dynamically handle calls to the class.
in
Macroable at line 103
mixed
__call(string $method, array $parameters)
Dynamically handle calls to the class.
at line 89
__construct(string $name, SessionHandlerInterface $handler, string|null $id = null, string $serialization = 'php')
Create a new session instance.
at line 118
bool
start()
Start the session, reading the data from a handler.
at line 132
protected array
getAttributes()
Get the session attributes.
at line 140
protected void
setAttributes(array $attributes)
Set the session attributes.
at line 148
protected void
replaceAttributes(array $attributes)
Replace the session attributes.
at line 159
protected void
loadSession()
Load the session data from the handler.
at line 169
protected array
readFromHandler()
Read the session data from the handler.
at line 193
protected string
prepareForUnserialize(string $data)
Prepare the raw string data from the session for unserialization.
at line 201
protected array
marshalErrorBagIn(array $attributes)
Marshal the ViewErrorBag in the given session attributes.
at line 223
void
save()
Save the session data to storage.
at line 250
protected array
prepareErrorBagForSerialization(array $attributes)
Prepare the ViewErrorBag in the given session attributes for JSON serialization.
at line 273
protected string
prepareForStorage(string $data)
Prepare the serialized session data for storage.
at line 281
void
ageFlashData()
Age the flash data for the session.
at line 289
protected array
ageFlashDataIn(array $attributes)
Age the flash data in the given session attributes.
at line 301
array
all()
Get all of the session data.
at line 309
array
only(array $keys)
Get a subset of the session data.
at line 317
array
except(array $keys)
Get all the session data except for a specified array of items.
at line 325
bool
exists(array|UnitEnum|string $key)
Check if a key exists.
at line 337
bool
missing(array|UnitEnum|string $key)
Determine if the given key is missing from the session data.
at line 345
bool
has(array|UnitEnum|string $key)
Determine if a key is present and not null.
at line 355
bool
hasAny(array|UnitEnum|string $key)
Determine if any of the given keys are present and not null.
at line 365
mixed
get(UnitEnum|string $key, mixed $default = null)
Get an item from the session.
at line 373
mixed
pull(UnitEnum|string $key, mixed $default = null)
Get the value of a given key and then forget it.
at line 386
bool
hasOldInput(UnitEnum|string|null $key = null)
Determine if the session contains old input.
at line 396
mixed
getOldInput(UnitEnum|string|null $key = null, mixed $default = null)
Get the requested item from the flashed input array.
at line 404
void
replace(array $attributes)
Replace the given session attributes entirely.
at line 412
void
put(array|UnitEnum|string $key, mixed $value = null)
Put a key / value pair or array of key / value pairs in the session.
at line 429
mixed
remember(UnitEnum|string $key, Closure $callback)
Get an item from the session, or store the default value.
at line 443
void
push(UnitEnum|string $key, mixed $value)
Push a value onto a session array.
at line 455
int|float
increment(UnitEnum|string $key, int $amount = 1)
Increment the value of an item in the session.
at line 465
int|float
decrement(UnitEnum|string $key, int $amount = 1)
Decrement the value of an item in the session.
at line 473
void
flash(UnitEnum|string $key, mixed $value = true)
Flash a key / value pair to the session.
at line 487
void
now(UnitEnum|string $key, mixed $value)
Flash a key / value pair to the session for immediate use.
at line 499
void
reflash()
Reflash all of the session flash data.
at line 509
void
keep(mixed $keys = null)
Reflash a subset of the current flash data.
at line 519
protected void
mergeNewFlashes(array $keys)
Merge new flash keys into the new flash array.
at line 529
protected void
removeFromOldFlashData(array $keys)
Remove the given keys from the old flash data.
at line 537
void
flashInput(array $value)
Flash an input array to the session.
at line 545
Repository
cache()
Get the session cache instance.
at line 553
mixed
remove(UnitEnum|string $key)
Remove an item from the session, returning its value.
at line 566
void
forget(array|UnitEnum|string $keys)
Remove one or many items from the session.
at line 579
void
flush()
Remove all of the items from the session.
at line 587
bool
invalidate()
Flush the session data and regenerate the ID.
at line 605
bool
regenerate(bool $destroy = false)
Generate a new session identifier.
at line 615
bool
migrate(bool $destroy = false)
Generate a new session ID for the session.
at line 631
bool
isStarted()
Determine if the session has been started.
at line 639
string
getName()
Get the name of the session.
at line 650
void
setName(string $name)
Set the name of the session.
Boot-only. Mutates the shared session store name; per-request use races across coroutines and changes the cookie name for concurrent requests.
at line 658
string
id()
Get the current session ID.
at line 666
string
getId()
Get the current session ID.
at line 682
void
setId(string|null $id)
Set the session ID.
at line 693
bool
isValidId(string|null $id)
Determine if this is a valid session ID.
at line 701
protected string
generateSessionId()
Get a new, random session ID.
at line 709
void
setExists(bool $value)
Set the existence of the session on the handler if applicable.
at line 719
string|null
token()
Get the CSRF token value.
at line 727
void
regenerateToken()
Regenerate the CSRF token value.
at line 735
bool
hasPreviousUri()
Determine if the previous URI is available.
at line 745
Uri
previousUri()
Get the previous URL from the session as a URI instance.
at line 757
string|null
previousUrl()
Get the previous URL from the session.
at line 765
void
setPreviousUrl(string $url)
Set the "previous" URL in the session.
at line 773
string|null
previousRoute()
Get the previous route name from the session.
at line 781
void
setPreviousRoute(string|null $route)
Set the "previous" route name in the session.
at line 792
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.
at line 802
SessionHandlerInterface
getHandler()
Get the underlying session handler implementation.
at line 814
SessionHandlerInterface
setHandler(SessionHandlerInterface $handler)
Set the underlying session handler implementation.
Boot-only. 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.
at line 822
bool
handlerNeedsRequest()
Determine if the session handler needs a request.
at line 830
void
setRequestOnHandler(Request $request)
Set the request on the handler instance.
at line 840
static void
flushState()
Flush all static state.