SessionCookie

public struct SessionCookie

Defines the properties of an HTTP Cookie which will be used for a TypeSafeSession. It is valid for multiple TypeSafeSession types to use the same name (i.e. same cookie), provided they also use the same secret.

Usage Example:

static let sessionCookie = SessionCookie(name: "kitura-session-id", secret: "xyz789", secure: false, maxAge: 300)
  • The name of the cookie - for example, “kitura-session-id”

    Declaration

    Swift

    public let name: String
  • Create a new CookieSetup instance which controls how session cookies are created. At minimum, the name and secret fields must be specified.

    The same name value may be used across multiple TypeSafeSession implementations, resulting in a single session cookie being provided to the client. However in this case the same secret must also be used.

    Usage Example:

    static let sessionCookie = SessionCookie(name: "kitura-session-id", secret: "xyz789", secure: false, maxAge: 300)
    

    Declaration

    Swift

    public init(name: String, secret: String, secure: Bool = false, path: String? = nil, domain: String? = nil, maxAge: TimeInterval? = nil)

    Parameters

    name

    The name of the cookie, for example, ‘kitura-session-id’.

    secret

    The secret data used to encrypt and decrypt session cookies with this name.

    secure

    Whether the cookie should be provided only over secure (https) connections. Defaults to false.

    path

    The path for which this cookie should be supplied. Defaults to allow any path.

    domain

    The domain to which this cookie applies. Defaults to the subdomain of the server issuing the cookie.

    maxAge

    The maximum age (in seconds) from the time of issue that the cookie should be kept for. This is a request to the client and may not be honoured.