W3cubDocs

/Nim

Module cookies

This module implements helper procs for parsing Cookies.

Imports

strtabs, times

Procs

proc parseCookies(s: string): StringTableRef {...}{.raises: [], tags: [].}

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:

doAssert parseCookies("a=1; foo=bar") == {"a": 1, "foo": "bar"}.newStringTable
proc setCookie(key, value: string; domain = ""; path = ""; expires = ""; noName = false;
              secure = false; httpOnly = false): string {...}{.raises: [], tags: [].}
Creates a command in the format of Set-Cookie: key=value; Domain=...; ...
proc setCookie(key, value: string; expires: DateTime | Time; domain = ""; path = "";
              noName = false; secure = false; httpOnly = false): string
Creates a command in the format of Set-Cookie: key=value; Domain=...; ...

© 2006–2018 Andreas Rumpf
Licensed under the MIT License.
https://nim-lang.org/docs/cookies.html