mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-18 05:20:31 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user