Class
SessionsMiddleware
Uses HTTP cookies to save and restore sessions for connecting clients.
final class SessionsMiddleware
Overview
If a cookie matching the configured cookie name is found on an incoming request, the value will be used as an identifier to find the associated Session.
If a session is used during a request (Request.session()), a cookie will be set on the outgoing response with the session’s unique identifier. This cookie must be returned on the next request to restore the session.
app.middleware.use(app.sessions.middleware)
See SessionsConfig and Sessions for more information.
Topics
Initializers
init(session: any SessionDriver, configuration: SessionsConfiguration)Creates a newSessionsMiddleware.
Instance Properties
let session: any SessionDriverSession store.
Instance Methods
func respond(to: Request, chainingTo: any Responder) -> EventLoopFuture<Response>Called with eachRequestthat passes through this middleware.
Relationships
Conforms To
MiddlewareSwift.SendableSwift.SendableMetatype