Add security tip for setCookie (#19117)

* Add security tip for setCookie

* Update lib/pure/cookies.nim

Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>

* Update lib/pure/cookies.nim

Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>

Co-authored-by: Andreas Rumpf <rumpf_a@web.de>
Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
Co-authored-by: konsumlamm <44230978+konsumlamm@users.noreply.github.com>
This commit is contained in:
Federico Ceratto
2021-11-11 07:41:21 +00:00
committed by GitHub
parent 77b696c2c9
commit 036d894e6a

View File

@@ -50,6 +50,9 @@ proc setCookie*(key, value: string, domain = "", path = "",
maxAge = none(int), sameSite = SameSite.Default): string =
## 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`.
result = ""
if not noName: result.add("Set-Cookie: ")
result.add key & "=" & value