Vapor Documentation Beta

Structure HTTPCookies.​Value

public struct Value: ExpressibleByStringLiteral

A single cookie (key/value pair).

%3 HTTPCookies.Value HTTPCookies.Value ExpressibleByStringLiteral ExpressibleByStringLiteral HTTPCookies.Value->ExpressibleByStringLiteral

Member Of

HTTPCookies

A collection of HTTPCookies.

Conforms To

ExpressibleByStringLiteral

Initializers

init(string:​expires:​max​Age:​domain:​path:​is​Secure:​is​HTTPOnly:​same​Site:​)

public init(string: String, expires: Date? = nil, maxAge: Int? = nil, domain: String? = nil, path: String? = "/", isSecure: Bool = false, isHTTPOnly: Bool = false, sameSite: SameSitePolicy? = nil)

Creates a new HTTPCookieValue.

let cookie = HTTPCookieValue(string: "123")

Parameters

value

Value for this cookie.

expires Date?

The cookie's expiration date. Defaults to nil.

max​Age Int?

The maximum cookie age in seconds. Defaults to nil.

domain String?

The affected domain at which the cookie is active. Defaults to nil.

path String?

The path at which the cookie is active. Defaults to "/".

is​Secure Bool

Limits the cookie to secure connections. Defaults to false.

is​HTTPOnly Bool

Does not expose the cookie over non-HTTP channels. Defaults to false.

same​Site Same​Site​Policy?

See HTTPSameSitePolicy. Defaults to nil.

init(string​Literal:​)

public init(stringLiteral value: String)

See ExpressibleByStringLiteral.

Properties

expired

let expired: Value

An expired HTTPCookieValue.

string

var string: String

The cookie's value.

expires

var expires: Date?

The cookie's expiration date

max​Age

var maxAge: Int?

The maximum cookie age in seconds.

domain

var domain: String?

The affected domain at which the cookie is active.

path

var path: String?

The path at which the cookie is active.

is​Secure

var isSecure: Bool

Limits the cookie to secure connections.

is​HTTPOnly

var isHTTPOnly: Bool

Does not expose the cookie over non-HTTP channels.

same​Site

var sameSite: SameSitePolicy?

A cookie which can only be sent in requests originating from the same origin as the target domain.

This restriction mitigates attacks such as cross-site request forgery (XSRF).

Methods

serialize(name:​)

public func serialize(name: String) -> String

Seriaizes an HTTPCookie to a String.