Instance Methodhummingbird-auth 2.0.1HummingbirdAuth
save(session:expiresIn:)
save new or exising session
func save(session: SessionType, expiresIn: Duration) async throws -> Cookie
Saving a new session will create a new session id and returns a cookie setting the session id. You need to then return a response including this cookie. You can either create an Response
directly or use EditedResponse
to generate the response from another type.
let cookie = try await sessionStorage.save(session: session, expiresIn: .seconds(600))
var response = EditedResponse(response: responseGenerator)
response.setCookie(cookie)
return response
If you know a session already exists it is preferable to use update(session:expiresIn:request:)
.