funct parseCookies() { /* ** Grab the cookies from the CGI environment and extract the ** values. Store the names and values in a couple of global ** arrays so that getCookie can access them. */ $cookieLine = $HTTP_COOKIE; $tmpCookies = split($cookieLine, ";"); $loop = 0; while($loop < # $tmpCookies) { $name = substr($tmpCookies[$loop]," *([^=]*).*","$1"); $value = substr($tmpCookies[$loop],"[^=]*=(.*)","$1"); @cookieNames[$loop] = $name; @cookieValues[$loop] = $value; $loop++; } @cookiesParsed = "Y"; } funct getCookie(char $name) { /* ** If we haven't parsed the cookie environment variable yet ** then do it now. */ if (@cookiesParsed != "Y") { parseCookies(); } /* ** Scan through the cookies looking for the one that's been ** requested */ $count = 0; while ($count < # @cookieNames) { if (@cookieNames[$count] == $name) { return(@cookieValues[$count]); } $count++; } } funct setCookie(char $name, char $value) { addHttpHeader("Set-Cookie: $name=$value; path=/; expires=Mon, 01-Jan-2001 00:00:00 GMT"); }