Structure
SessionData
public struct SessionData
A container for storing data associated with a given SessionID
.
You can add data to an instance of SessionData
by subscripting:
let data = SessionData()
data["login_date"] = "\(Date())"
If you need a snapshot of the data stored in the container, such as for custom serialization to storage drivers, you can get a copy with .snapshot
.
let data: SessionData = ["name": "Vapor"]
// creates a copy of the data as of this point
let snapshot = data.snapshot
client.storeUsingDictionary(snapshot)
Relationships
Conforms To
Codable
ExpressibleByDictionaryLiteral
Initializers
init(initialData:)
public init(initialData data: [String: String])
Creates a session data container for the given data.
Parameters
Name | Type | Description |
---|---|---|
data | [String: String] |
The data to store in the container. |
init(from:)
public init(from decoder: Decoder) throws
init(dictionaryLiteral:)
public init(dictionaryLiteral elements: (String, String)...)
init(_:)
@available(*, deprecated, message: "use SessionData.init(initialData:)")
public init(_ data: [String: String])
Properties
Methods
encode(to:)
public func encode(to encoder: Encoder) throws
Operators
==
public static func ==(lhs: SessionData, rhs: SessionData) -> Bool