Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Perl cookie help

Status
Not open for further replies.

MagicChris

Programmer
May 30, 2001
28
GB
Right, i've attempted to pass a password in a cookie around so it will be remembered, usual login script.

But it won't work, and i don't know why not.

Anyway, here's the script,
Any help would be great, newbie kinda here. :)
 
this is what you have:
if (lc $in{'pass'}) {
if (lc $in{'pass'} eq lc $password) {
&authp;
}
if (lc $in{'pass'} ne lc $password) {
&authpp;
}
}

try this:
if (lc $in{'pass'}) {
if (lc $in{'pass'} eq lc $cookie{password}) {
&authp;
}
if (lc $in{'pass'} ne lc $cookie{password}) {
&authpp;
}
}
 
That won't work coz the cookie is set after the password is entered for the first time.

I think there's something wrong with the actual writing of the cookie, but i don't know what...
 
A couple of things: <<EOF; already interpolates so you don't have to put double quotes and you don't have to escape double quotes; I used CGI.pm but you can always change it back; I switched around some of your logic (the script only checks once for the password and I combined authp and authpp.); Your cookie was never written to the browser because its a part of the http header and you had content-type already declared (I had to move the content-type, header, and footer, to each individual display sub ); if you use my with more than one variable you need to place parenthesis around them, i.e. my( @this, $that, %theother ), and I used strict with my scoping and turned on the -w switch. I also have Carp displaying your errors to the browser for the convenience of bug tracking but you should remove it once your script is complete. I hope this helps and if you have any questions feel free to ask.

Johnny

The revised code can be viewed at:

P.S. The code has been tested.
 
Hey,
Thanks a lot! works brilliantly,

Thanks for your time :D

Chris
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top