Beyond the Basics |
New Cookie Issue |
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
For some reason, I am having problem with cookies again. I thought I had them beat some time ago and can't help but feeling I'm missing something rather simple (isn't that usually the case?). They seem to be writing fine, but my call to get them doesn't appear to be operating correctly - though looking at it, I can't for the life of me determine why. If you could help steer me in the right direction, it would be much appreciated. Set cookies: http://egowhores.com/linkage Name: user Password: password Then close out that screen and click: http://egowhores.com/cgi-bin/pl/plink.pl The action performed by this link is: if (! $action) { cookies("get"); header(); print qq~Info from env content: <b>$ENV{'HTTP_COOKIE'}</b><br><br>~; print qq~Line 1:<b>$cookies[0]</b><br>Line 2:<b>$cookies[1]</b>~; }#End if no action clause The subroutine for cookies is: # cookies("get / set / clear"); sub cookies { my $action = $_[0];# action to perform = set, get, clear my (@cookies, $name, $value, $key); if ($action =~ /get/i) { # GET cookies foreach (split(/; /, $ENV{'HTTP_COOKIE'})) { s/\+/ /g; s/%([A-Fa-f0-9]{2})/pack("c",hex($1))/ge; ($name, $value) = split(/=/,$_,2); if ($name eq "egowhores") { @cookies = split(/\|/, $value); $cookie{aID} = $cookies[0]; $cookie{aPassword} = $cookies[1]; } else { $cookie{$name} = $value; } } } elsif ($action =~ /set/i) { # SET cookies $value = "$cookie{aID}\|$cookie{aPassword}"; $Expires = "Wed, 23-Feb-2005 00:00:00 GMT"; print qq~Set-Cookie: egowhores=$value;expires=$Expires;path=/;\n~; } else { $value = ""; $Expires = "Sun, 31-Dec-2000 00:00:00 GMT"; print qq~Set-Cookie: egowhores=$value;expires=$Expires;path=/;\n~; undef %cookie; } }#end SR cookies |
||
© Copyright 2004 C.G. Ward - All Rights Reserved | |||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
By the way - the cookie sub-routine should look familiar, Ron, as it's almost exactly what you gave me a year and a half ago (had it working then too). |
||
Mysteria
since 2001-03-07
Posts 18328British Columbia, Canada |
After reading that I need a coffee and of course, a cookie! |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
I'll take a closer look at the code tomorrow, if necessary, when I'm not quite so brain-dead. I doubt it will be necessary, though, as I doubt there are any problems with the code. If memory serves, Chris, you initially ran into the same problem last time? Put both scripts in the same directory and I suspect it will magically start working. |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
Scratch that. If you can print the ENV variable, it's not a path problem. I'll be back … |
||
Ron
Administrator
Member Rara Avis
since 1999-05-19
Posts 8669Michigan, US |
Okay, here's your problem, Chris. In the cookies function you are declaring the scalar array @cookies locally (with my), but then you try printing it in the calling routine as if it were global. That won't work because the array was destroyed the minute you left the routine where it was declared. Try printing out the hash variables, $cookie{aID} and $cookie{aPassword}, instead. The hash called cookie "should" be global. |
||
Midnitesun
since 2001-05-18
Posts 28647Gaia |
Wow, what a lesson in code! All I want is a simple oatmeal raisin cookie with gourmet java. BTW Ron, I will be changing my email addy (again!) in two weeks. Should I be deleting all my cookies before the move, and eliminate access to the DM forums? When I reconnect the PC will end up in my daughter's bedroom, and she doesn't need to have adult/DM access. Thanks! Midnitesun (unplugging this on Feb 11) |
||
Christopher
Moderator
Member Rara Avis
since 1999-08-02
Posts 8296Purgatorial Incarceration |
I even looked at that too, Ron, but didn't even connect that by declaring the array as local [my], that it would extend to the variables broken out as well... which makes complete sense in retrospect. Thank you Ron, as always, your help is not only help, but educational. Much appreciated. Sharon - sounds good, pass some my way??? MidniteSun: If you go to the member's section at the top of the page, there is a place where you can manipulate your cookies to "remember you". If you disable that, you can later log in and log out without having to worry about your daughter having access to what you feel is inappropriate material. C |
||
Susan Caldwell Member Rara Avis
since 2002-12-27
Posts 8348Florida |
oh my. zing, right over my head. and you know what? I like it that way. geez. Make mine chocolate chip. |
||
Obscurity Member
since 2003-12-04
Posts 153In A Melancholic Dream |
Perl, the only language that looks the same before and after it goes through the RSA Algorithm :P |
||
⇧ top of page ⇧ | ||
All times are ET (US). All dates are in Year-Month-Day format. |