cgiputcookie() - print arbitrary cookie header

SYNOPSIS

#include "cgi.h"

int   cgiputcookie(cp, name, val, domain, path, secure, expire)
CGI  *cp;
char *name, *val, *domain, *path;
int   secure;
long  expire;


DESCRIPTION
The cgiputcookie() function prints a Set-Cookie header for an arbitrary cookie called name with value val. The string val is URL-escaped when printed, so all characters (ASCII 1-255) are valid. The remaining parameters are optional and can be set to CHARPN or 0 for defaults.

The domain parameter is the domain that the cookie is valid for; it should contain at least two dots (default: the current host). The path parameter is the root of the document hierarchy that the cookie is valid for (default: "/" for all documents). The secure parameter can be set non-zero to flag the cookie as secure: the browser should only return the cookie over secure sessions (as defined by the browser; the default is 0: always send the cookie). The expire parameter is the expiration time (in seconds from now); it can be negative to forcibly expire a cookie (default if 0: one hour).

All HTTP cookies sent by the Web client, including any set with cgiputcookie() during previous invocations, can be retrieved with getcgi() or cgivar() with a value of CGI_COOKIE.

The cgiputcookie() function, if used, must be called between cgistarthdrs() and cgiendhdrs(), as it prints an HTTP header. It returns 1 on success, 0 if error (e.g. current browser doesn't support cookies).


SEE ALSO
getcgi() cgivar()


Copyright © Thunderstone Software     Last updated: Apr 15 2024
Copyright © 2024 Thunderstone Software LLC. All rights reserved.