Phoenix.pm: Damn Cookies

David Sinck sinck at ip100.starwarz.org
Mon Aug 9 11:43:28 CDT 1999



\_ OK, I am going crazy. I have been trying all day to get a very easy script
\_ to work and it won't. The basic idea is just writing a cookie. I have
\_ tried it in the perlscript itself, and then, in desperation, commented out
\_ the perl cookie stuff and tried javascript. Everytime I check the cookie
\_ file, I get zilch. 

The cookie file may or may not get written unless you bail from the
browser entirely *with* a cookie with an expiration time longer than
your current session.  :-)

\_ I just want to make a damn cookie and add info to it. What am I doing
\_ wrong?
The previous votes for a newline in the header and use CGI have quite
a bit of merit.  I've written a shopping cart system use'ing CGI that
used cookies, and CGI was the way to go.

Here's an amusing cookie-viewing Netscape bookmark for you:

JavaScript: if (document.cookie.length > 0) {var str = %22%22; arr = document.cookie.split(';'); for (var i=0; i < arr.length; i++) {str = unescape(arr[i]) + %22\r\n%22 + str } alert(document.location + %22\r\n%22 + str)} else {alert(%22Cookies Have Been Stolen\r\nFrom %22 + document.location)}

I have that all as one line in the bookmark rather than multiple
lines.  In case your mail reader folds it, take the following and
concatenate it w/o the newlines:

JavaScript: if (document.cookie.length > 0) 
{var str = %22%22; arr = document.cookie.split(';'); 
for (var i=0; i < arr.length; i++) 
{str = unescape(arr[i]) + %22\r\n%22 + str } 
alert(document.location + %22\r\n%22 + str)} 
else {alert(%22Cookies Have Been Stolen\r\nFrom %22 + document.location)}

It's not quite as robust or thorough or consistent as it could be, but
it works for me.  :-)

David



More information about the Phoenix-pm mailing list