Skip to content

Commit

Permalink
Add security tip for setCookie (#19117)
Browse files Browse the repository at this point in the history
* Add security tip for setCookie

* Update lib/pure/cookies.nim

Co-authored-by: Dominik Picheta <[email protected]>

* Update lib/pure/cookies.nim

Co-authored-by: konsumlamm <[email protected]>

Co-authored-by: Andreas Rumpf <[email protected]>
Co-authored-by: Dominik Picheta <[email protected]>
Co-authored-by: konsumlamm <[email protected]>
  • Loading branch information
4 people authored Nov 11, 2021
1 parent 77b696c commit 036d894
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/pure/cookies.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 036d894

Please sign in to comment.