in reply to Re: Re: Re: Re: Cookie not getting stores
in thread Cookie not getting stores
Something like this might work for you:
my $pass = cookie('cookie'); # if there was a cookie named 'pass' if ( defined $pass) { # if the password in the cookie matches the admin password if ($pass eq $adminpass) { # do administrative stuff } } # there's no cookie, so check for a 'pass' parameter else { $pass = param( 'pass' ); if ($pass eq $adminpass) { # set admin cookie # make sure the name is 'pass' so you can retrieve it # redirect to the current script } }
You might also look in the examples shipped with CGI.pm. cookies.cgi and customize.cgi are pretty good.
Again, simply declaring a hash named %cookie does absolutely nothing to retrieve a cookie. This seems to be the source of your confusion. You could call your hash %not_a_cookie or %magic_php_variable and it would do nothing, since Perl does not care what you name your variables. It does not automatically fill in values for you. You have to retrieve a cookie by name and check its value against the value you have.
Earlier versions of PHP did automagically create variables named after CGI variables, but it's been deprecated and not recommended for quite a while. I'm not aware that any Perl module ever did that -- it opens up a lot of security risks and can cause scary action at a distance.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Re: Re: Re: Re: Cookie not getting stores
by sulfericacid (Deacon) on Dec 26, 2003 at 21:44 UTC | |
by chromatic (Archbishop) on Dec 26, 2003 at 22:07 UTC |