This module implements helper procs for parsing Cookies.
Procs
proc parseCookies(s: string): StringTableRef {....raises: [], tags: [], forbids: [].}
-
Parses cookies into a string table.
The proc is meant to parse the Cookie header set by a client, not the "Set-Cookie" header set by servers.
Example:
import std/strtabs let cookieJar = parseCookies("a=1; foo=bar") assert cookieJar["a"] == "1" assert cookieJar["foo"] == "bar"
Source Edit proc setCookie(key, value: string; domain = ""; path = ""; expires = ""; noName = false; secure = false; httpOnly = false; maxAge = none(int); sameSite = SameSite.Default): string {. ...raises: [], tags: [], forbids: [].}
-
Creates a command in the format of Set-Cookie: key=value; Domain=...; ...Tip: Cookies can be vulnerable. Consider setting secure=true, httpOnly=true and sameSite=Strict.Source Edit