Home Contents | # cgi:cookie | Httpd/CGI | Core4 Lua Event System

## SYNOPSIS

cgi:cookie(name, value [, expires])

## DESCRIPTION

Sends a header line that instructs the client to set a cookie of name name to value.

Optionally an expiry date can be given. If no expiry is set, the cookie is a session cookie that is automatically deleted when the user's browser exits. The expiry date must be a date object.

The cgi:cookie() function can only be called while the request is still in the header phase. Once sending of the actual response content has been started, attempting to send any more headers will make the client mistake the header as content. The header phase ends once cgi:write() has been called at least once.

## SEE ALSO

cgi:addheader(), cgi:write()