Forum Moderators: coopster & phranque

Message Too Old, No Replies

Perl Cookies

Unable to Set or Retrieve - Help

         

rafiquea

8:42 pm on Dec 28, 2003 (gmt 0)



Below is the snippet of code. Two problems.

1. When I initially set the cookie, nothing is set until I hit the refresh button (e1.cgi).

2. When I call another CGI script with post from a form created with e1.cgi, the cookie is gone (e2.cgi). Although if I call the second CGI script from the browser, the cookie is there.

#perl script e1.cgi
...
$cookievalue="User 1";
print "Set-Cookie: user=${cookievalue}\n";
$words=$ENV{'HTTP_COOKIE'};
print <<__;
Content-type: text/html
$words <br>

<form method=post action="e2.cgi">
<INPUT type="submit" value="Submit">
</form>
__

#perl script e2.cgi
...
$words=$ENV{'HTTP_COOKIE'};
print <<__;
Content-type: text/html
$words <br>
</form>
__

volatilegx

8:25 pm on Dec 29, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In regards to your first problem, the cookie is probably being set, but isn't being displayed by your script because no cookie header was sent with the request for ei.cgi, therefore $ENV{'HTTP_COOKIE'} is empty.

Dan