author: laplante@plcb.ca date: 2024-03-17 title: “HTTP::SET_COOKIE Function” version: 1.0.0 section: 1g category: GOWEB/HTTP
http::set_cookie — Set or delete cookies http::setCookie — Set or delete cookies
http::set_cookie(name: string [, value: string, path: string, max_age: int, http_only: bool, secure: bool, same_site: int])
The http::set_cookie
function sends a cookie to the client’s browser.
It allows fine-grained control over cookie attributes such as expiration
time, security flags, and SameSite policies.
To delete a cookie, set its value to an empty string and max_age
to
-1
:
set_cookie(name: "session", value: "", max_age: -1);
/
.3600
.true
(default), the cookie cannot be
accessed via client-side scripts.true
(default), the cookie is only
transmitted over HTTPS.http::SameSiteStrictMode
.
http::SameSiteLaxMode
http::SameSiteStrictMode
http::SameSiteNoneMode
From OWASP:
// Set a cookie with relaxed SameSite policy
set_cookie(name: "cd", value: data.set, same_site: http::SameSiteNoneMode);