-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
misc cookies #602
Comments
TODO: max-age proc formatExpires*(time: Time): string =
result = format(time.utc, "ddd',' dd MMM yyyy HH:mm:ss 'GMT'") |
IIRC I needed something
here's what I wrote instead: proc addCookie*(headers: var Option[RawHeaders], cookie: string) =
# note: requires makeCookie eg: (key, value, expires: string, domain = "", path = "", secure = false, httpOnly = false, sameSite = Lax): string =
# EG: addCookie(result[2], cookie)
if isSome(headers) and
(let headers2 = headers.get(); headers2.toTable.hasKey("Set-Cookie")):
headers = some(headers2 & @({"Set-Cookie": cookie}))
else:
# Note: requires modif to jester
setHeader(headers, "Set-Cookie", cookie) |
I use something like this (adapted from jester API/code) proc removeCookie*(headers: var Option[RawHeaders], cookieKey: string, path = "") =
## https://stackoverflow.com/questions/5285940/correct-way-to-delete-cookies-server-side
let expires = "Thu, 01 Jan 1970 00:00:00 GMT"
# consider using fixed key for cookie value
let cookie = makeCookie(cookieKey, "", expires = expires, path = path)
addCookie(headers = headers, cookie = cookie) |
|
links
The text was updated successfully, but these errors were encountered: