webstudioro has asked for the wisdom of the Perl Monks concerning the following question:

Whay dont show the cookie? The $ENV{'HTTP-COOKIE'} dont show the cookie. Whay?

#!/usr/bin/perl require "admin_sub.pl"; require "uzual_sub.pl"; require "variabile.pl"; &readForm; if ($FORM{'verify'} eq "account") { if (($FORM{'user'} eq "$adminUser") && ($FORM{'pws'} eq "$adminPas +sword")) { print "Set-Cookie: $user=$pws; expires=; path=/; domain=localhost; +"; print "Content-type: text/html\n\n"; print "The cookie is: $ENV{'HTTP-COOKIE'}"; exit; } else { print "Content-type: text/html\n\n"; print "Username-ul sau parola nu sunt bune."; exit; } exit; } print "Content-type: text/html\n\n"; print <<ENDHTML; <html> <head> <title>$websiteTitle :: Shop Admin.</title> </head> <body> <table align=center border=0> <form action="http://localhost/cgi-bin/larrycenter/admin.pl" method="p +ost"> <input type=hidden name="verify" value="account"> <tr><td> User: <input type=text name="user"> Password: <input type=password name="pws"> <input type=submit value="Log in!"> </td></tr> </form> </table> </body> </html> ENDHTML exit;

update (broquaint): added <code> tags update (jeffa): title change (was: Whay?)

Replies are listed 'Best First'.
Re: Help with cookie not being displayed
by cLive ;-) (Prior) on Jul 11, 2003 at 09:14 UTC
    $ENV{'HTTP-COOKIE'} contains cookies sent from the browser. You've only just set it. The browser won't send the cookie until it next makes a request.

    cLive ;-)

    ps - please use strict, use warnings, and use CGI !!!

Re: Help with cookie not being displayed
by antirice (Priest) on Jul 11, 2003 at 09:25 UTC

    ++cLive ;-)'s wisdom is as true today as it was 11 minutes ago when he posted it (I always wanted to say that...so I apologize for starting that way). Also of worthy note is that you should be checking $ENV{'HTTP_COOKIE'} (or possibly $ENV{'COOKIE'}, depending upon webserver) instead of $ENV{'HTTP-COOKIE'}.

    antirice    
    The first rule of Perl club is - use Perl
    The
    ith rule of Perl club is - follow rule i - 1 for i > 1