set more than one cookie

Jan M.J. Storms jan at storms.org
Mon Oct 14 06:14:10 PDT 2002


This one was driving me up the wall: is it actually possible to set
multiple cookies in one response?

If I set more than one cookie (using webserver.util.setcookie) only the
first was accepted by the browser (tried it with omniweb and explorer,
latest versions on OsX).

<http://wp.netscape.com/newsref/std/cookie_spec.html> says: "Multiple
Set-Cookie headers can be issued in a single server response." But that
sounds as if you have to format them differently from what
webserver.utils.setcookie does.

So I figured it out:

in webserver.util.setcookie:

if defined (adrcookie^) {
	adrcookie^ = adrcookie^ + "\r\n" + s}

needs to be:

if defined (adrcookie^) {
	adrcookie^ = adrcookie^ + ("\r\nSet-Cookie: " + s);}


I also found a problem with the line:

local (s = cookieName + "=" + string.urlEncode (cookieValue))

because it translates my "="-characters and found it better to use the
webserver.encodeArgs procedure

Jan Storms




More information about the Frontier-Users mailing list