in reply to Re: Re: yummm...cookies, anyone?
in thread yummm...cookies, anyone?
First thing first: print header(-cookie=>'sessionID') prints a header like this:
Set-Cookie: sessionID Date: Mon, 04 Aug 2003 02:50:03 GMT Content-Type: text/html; charset=ISO-8859-1
Which I believe is not what you were hoping for. Use cookie() to return something that will work. Now here is your program in pseudocode:
You may notice the emphasis on part 2 and part 4.5. The cookie MUST be placed within the header. Check everything prior to printing the header.
Update: Ugh...sarcasm...*sigh*. So you know I'm not a bad guy:
my %options; my $cookie; if (cookie('sessionID') && checkSessionID(cookie('sessionID'))) { $cookie = cookie(-name => 'sessionID', -value => cookie('sessionID'), -expires => '+1h', -path => '/'); } # you may notice I don't use -secure=>1...this is because # you require an ssl certificate to be present for the # cookie to work (although not all browsers really follow it) elsif (param('username') && param('password') && checkUserPass(param(' +username'),param('password))) { $cookie = cookie(-name => 'sessionID', -value => makeCookie(param('username'),param('pas +sword)), -expires => '+1h', -path => '/'); } $options{"-cookie"} = $cookie if $cookie; print header(%options),start_html; # now if $cookie is set, print stuff as if they're logged in
Hope this helps.
antirice
The first rule of Perl club is - use Perl
The ith rule of Perl club is - follow rule i - 1 for i > 1
|
|---|