Skip to content

Class

Session

Sessions are a method for associating data with a client accessing your app.
final class Session

Overview

Each session has a unique identifier that is used to look it up with each request to your app. This is usually done via HTTP cookies.

See Request.session() and SessionsMiddleware for more information.

Topics

Initializers

Instance Properties

  • data
    This session’s data.
  • id
    This session’s unique identifier. Usually a cookie value.

Instance Methods

  • authenticate(_:)
    Authenticates the model into the session.
  • authenticated(_:)
    Returns the authenticatable type’s ID if it exists in the session data.
  • destroy()
    Invalidates the current session, removing persisted data from the session driver and invalidating the cookie.
  • unauthenticate(_:)
    Un-authenticates the model from the session.

Relationships

Conforms To

  • Swift.Sendable
  • Swift.SendableMetatype