Creates a new session instance
Session configuration
Factory function to create session store
Event emitter service
HTTP context
Store of flash messages that will be written during the HTTP request
Store of flash messages for the current HTTP request
The key used for storing flash messages inside the session store
Session configuration
Gets the session id for the current HTTP request
Returns true if a fresh session was created during the request
Returns true if the session is in readonly state
Returns true if the session store has been initiated
Returns true if the session id has been re-generated during the current request
Returns true if the session store is empty
Returns true if the session store has been modified
Puts a key-value pair to the session data store
The key to store the value under
The value to store
Gets the value of a key from the session datastore. You can specify a default value to use when key does not exist or has undefined value.
The key to retrieve
OptionaldefaultValue: any
Default value to return if key doesn't exist
Reads value for a key from the session datastore and removes it simultaneously
The key to pull
OptionaldefaultValue: any
Default value to return if key doesn't exist
Increments the value of a key inside the session store. A new key will be defined if it doesn't exist already with value 1.
The key to increment
Number of steps to increment (default: 1)
Decrements the value of a key inside the session store. A new key will be defined if it doesn't exist already with value -1.
The key to decrement
Number of steps to decrement (default: 1)
Adds a key-value pair to flash messages
The key or object of key-value pairs to flash
The value to flash (when key is a string)
Flashes errors to the errorsBag. You can read these errors via the "@error" tag. Appends new messages to the existing collection.
Collection of error messages
Flashes error messages for form fields to the inputErrorsBag, the same bag "flashValidationErrors" fills. The "@inputError" tag and the Inertia adapter read them like validation errors. Messages are appended to the ones already flashed for a field.
Error messages keyed by field name
Flashes validation error messages. Make sure the error is an instance of VineJS ValidationException. Overrides existing inputErrors.
HTTP error containing validation messages
Tag the current session with a user ID. Only supported by Memory, Redis, and Database stores. This enables features like "logout from all devices".
The user ID to tag this session with
Store a URL as the intended redirect destination. The URL is
validated using isValidRedirectUrl before storing. Invalid
URLs are silently ignored.
The URL to store as the intended destination
Returns the intended URL without consuming it, or null
if no intended URL is stored.
Returns the intended URL and removes it from the session,
or null if no intended URL is stored.
Removes the intended URL from the session.
The session class exposes the API to read and write values to the session store.
A session instance is isolated between requests but uses a centralized persistence store.
Example