webserver.util.setCookie

Syntax webserver.util.setCookie (adrParams, cookieName, cookieValue, cookieDomain, cookieExpires, cookiePath, flSecure)

Params adrParams is the address of the parameter table created by Frontier's responder framework.

cookieName is the name of the cookie.

cookieValue is the value of the cookie. Together, cookieName and cookieValue make up the name=value pair constituting the key datum of the cookie.

cookieDomain (optional) is a string which should tail-match the domain of a requested URL if the browser is to submit this cookie along with the request; if omitted, the browser will use the domain of the present request.

cookieExpires (optional) is date or a string expressing the date and time at which the browser may let this cookie expire. If it's a date, it is converted to a string in the proper cookie date-string format.

cookiePath (optional) is a string that must match some part of a requested URL (after the host name) if the browser is to submit this cookie along with the request; the default is "/", which is always a match.

flSecure (optional) is a boolean which, if true, tells the browser not to transmit the cookie except via https; the default is false.

Action Constructs a cookie string and stores it as, or appends it to, the Set-Cookie entry in the parameter table's ResponseHeaders table, thus causing the cookie to be sent to the client along with the returned page.

Returns The cookie string, which in general you will throw away.

Examples // Put this in the #security script of a Web site table:

if not defined (requestheaders.cookies.howdy) // no incoming cookie
   webserver.util.setCookie (parentof(request), "howdy", "friend")
else
   msg (requestheaders.cookies.howdy)

   » "friend"

// Through MainResponder, request a page within that table. The browser will be sent the cookie. Request a page within that table again. The browser will submit the cookie, whose value ("friend") is displayed in the About window.
Notes If you aren't familiar with cookies, it may help to study http://home.netscape.com/newsref/std/cookie_spec.html.

Discuss