UpdateWebCookie (open)

Set or update a cookie on the client

Syntax

LOADLIB "mod::system/lib/webserver.whlib";

MACRO UpdateWebCookie(STRING name, STRING value, RECORD options)

Parameters

STRING name

Cookie name

STRING value

Cookie value. If left empty, the existing cookie with the name will be deleted. Setting non-ASCII data is not recommended for unencrypted cookies

RECORD options

Cookie options

STRING domain

Cookie domain. Defaults to empty, in which case the cookie will be valid for the current host only

BOOLEAN encrypt

If true, the cookie will be encrypted. Defaults to false

BOOLEAN httponly

If true, mark a cookie as 'httponly', making it invisible to Javascript and helping to mitigate the damage of XSS attacks. Defaults to true

INTEGER64 lifetime

Cookie maximum age (Max-Age) in seconds. If 0, the cookie will be a session cookie (the default)

STRING path

Cookie path. Defaults to "/", making the cookie available for all URLs on this domain

STRING samesite

SameSite setting (empty, 'none', lax' or 'strict')

STRING secretkey

The secret encryption key to use. If empty, a server generated key will be used.

BOOLEAN secure

If true, mark a cookie to only be transferred over secure connections.

Description

This function will set or update the value of a cookie on the client. Using this macro does not directly affect GetWebCookie, but should affect it on the next call.