FireBird34 has asked for the wisdom of the Perl Monks concerning the following question:
if($query{'action'} eq 'Login'){ setCookie(); }else{ head(); #header subroutine fetchCookie(); #displays results ## ... other misc stuff... } sub setCookie { $cookie1 = new CGI::Cookie(-name => 'cookie name', -value => 'value here', -expires => '+3M', -path => '/', ); print "Set-Cookie: $cookie1\n"; print header; print '<meta http-equiv="refresh" content="2">'; }
I've been at this for hours, and can't seem to find why setting the cookie outside the if statement will work, while having it inside the if statement will not work. I have tried several different ways of doing this, yet nothing. And yes, I have checked to see if $query{'action'} does equal 'Login'. Everything in the if statement works, EXCEPT the setting of the cookie. Any thoughts?setCookie(); if($query{'action'} eq 'Login'){ #setCookie(); }else{ head(); #header subroutine fetchCookie(); #displays results ## ... other misc stuff... } sub setCookie { $cookie1 = new CGI::Cookie(-name => 'cookie name', -value => 'value here', -expires => '+3M', -path => '/', ); print "Set-Cookie: $cookie1\n"; print header; print '<meta http-equiv="refresh" content="2">'; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Playing with Cookies
by almut (Canon) on Dec 23, 2009 at 00:11 UTC | |
|
Re: Playing with Cookies
by Khen1950fx (Canon) on Dec 23, 2009 at 01:09 UTC | |
by Anonymous Monk on Dec 23, 2009 at 23:42 UTC | |
|
Re: Playing with Cookies
by Anonymous Monk on Dec 23, 2009 at 00:13 UTC | |
|
Re: Playing with Cookies
by Anonymous Monk on Dec 23, 2009 at 23:56 UTC | |
by FireBird34 (Pilgrim) on Dec 27, 2009 at 14:25 UTC |