SessionMiddleware class
Gives each request a session (req.session) and saves it after the
controller. Settings come from AppConfig.session.
AppConfig(
globalMiddleware: <dynamic>[SessionMiddleware(), CsrfMiddleware()],
);
With the cookie driver the cookie is decrypted and read on first
use. With the cache driver the store is read before the controller,
but only when the request has a session cookie. The session API is
not async, so the store can not be read later.
The cookie is sent only when the session changed.
- Implemented types
Constructors
- SessionMiddleware([SessionConfig? _config])
-
config wins over
AppConfig.session.const
Properties
- config → SessionConfig
-
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
fromCookie(
String? cookie) → Future< Session> -
The session of
cookie: the session cookie value as the browser sent it (still encrypted). For code with no request, like a socket. It has the same checks as this middleware: a changed or foreign cookie, a cookie made with another key, an expired session or an unknown id gives an empty session. Changes to it are not saved. -
handle(
DoxRequest req, Next next) → Future< DoxResponse> -
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
requestOf(
HttpRequest req) → DoxRequest? -
The request of
reqwhen it runs this middleware, else null. TheExceptionHandleruses it to redirect back with errors.
Constants
- maxCookieSize → const int
- cookie limit of the browsers, name and value together