public final class SessionsMiddleware: Middleware
Uses HTTP cookies to save and restore sessions for connecting clients.
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
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.
var middlewareConfig = MiddlewareConfig() middlewareConfig.use(SessionsMiddleware.self) services.register(middlewareConfig)
Sessions for more information.
Middlewareis placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses.
Middlewarecan choose to pass requests on to the next
Middlewarein a chain, or they can short circuit and return a custom
public init(session: SessionDriver, configuration: SessionsConfiguration = .default())
Creates a new
let session: SessionDriver