SessionsMiddleware

public final class SessionsMiddleware : Middleware, ServiceType

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 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.

var middlewareConfig = MiddlewareConfig()
middlewareConfig.use(SessionsMiddleware.self)
services.register(middlewareConfig)

See SessionsConfig and Sessions for more information.