[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

[MacPerl] Cookies, and again, cookies!



Hi there,

I've been trying to use cookies with Perl, but CGI.pm has proved to be
extremely frustrating.  I have an html form that sends a single value,
'login', to the script.  The script is then supposed to create cookie
from the single login value, retrieve the cookie and print it in the
browser.  I've read all the examples, sample scripts, manuals etc, but I
cannot understand why this doesn't work.

#!/usr/local/bin/perl
use CGI;
$query = new CGI;

$login_value = $query->param('login');                #get from form

$cookie = $query->cookie(-name=>'login',              #Create cookie
                         -value=>"$login_value",
                         -expires=>'+1h',
                         -path=>'/cgi-bin/',
                         -domain=>'.soth.zoneit.com');

print $query->header(-cookie=>$cookie);               $get cookie

$login_from_cookie = $query->cookie(-name=>'login');

print "Content-type:text/html";
print "<HTML><BODY>$login_from_cookie</BODY></HTML>";

Now, I'm getting extremely frustrated about all this.  I'm using
Netscape 4.5, and I even tried it with IE (shudder!) but this doesn't
work...period.  Could anyone enlighten me?  In any case, I'd really
appreciate if someone could post some cookie code that works!

Thanx

Sveinbjorn Thordarson
Reykjavik, Iceland

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org