UnderMine has asked for the wisdom of the Perl Monks concerning the following question:
The following code is supposed to store login username in a cookie or clear the existing cookie info if the login fails. The cookie is supposed to be persistant for upto 1yr if auto_login is checked.
The issue I am having trouble with is it is not persistant when set and it is not cleared down correctly.
I am currently at the serious hairloss stage and appear to be blind to the error of my ways.use CGI; use CGI::Carp qw{ fatalsToBrowser }; use CGI::Cookie; use strict; use HTML::Template; my $cgi = new CGI(); my $template; my $validated; # Validation of login removed if ($validated) { my $cookie = new CGI::Cookie(-name => 'star', -value => $cgi->param('username'), -expires => $cgi->param('auto_login')? +'+365d':'+3h'); print $cgi->header(-cookie=>$cookie); $template = HTML::Template->new(filename => 'login-success.tmpl', die_on_bad_params => 0); $template->param('successURL'=> $successurl); } else { my $cookie = new CGI::Cookie(-name => 'star', -value => undef, -expires => '+1s'); print $cgi->header(-cookie=>$cookie); $template = HTML::Template->new(filename => '../index.html', die_on_bad_params => 0); } print $template->output();
Asking for a bit a meditation
UnderMine
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
•Re: Persistant cookie issue.
by merlyn (Sage) on Nov 28, 2002 at 00:43 UTC | |
by UnderMine (Friar) on Nov 28, 2002 at 09:37 UTC | |
by merlyn (Sage) on Nov 28, 2002 at 15:20 UTC | |
by UnderMine (Friar) on Nov 28, 2002 at 16:32 UTC |