HTTP::SET_COOOKIE 1g 2024-03-17 laplante@plcb.ca GOWEB/HTTP


author: laplante@plcb.ca date: 2024-03-17 title: “HTTP::SET_COOKIE Function” version: 1.0.0 section: 1g category: GOWEB/HTTP


Name

http::set_cookie — Set or delete cookies http::setCookie — Set or delete cookies

Synopsis

http::set_cookie(name: string [, value: string, path: string, max_age: int, http_only: bool, secure: bool, same_site: int])

Description

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);

Parameters

Notes on SameSite

From OWASP:

Examples

// Set a cookie with relaxed SameSite policy
set_cookie(name: "cd", value: data.set, same_site: http::SameSiteNoneMode);

See also

Version