How to Join Member's Area Private Library Search Today's Topics p Login
Main Forums Discussion Tech Talk Mature Content Archives
   Nav Win
 Tech Talk
 Beyond the Basics
 New Cookie Issue
 1 2 3 4 5 6 7 8 9
Follow us on Facebook

 Moderated by: Ron   (Admins )

 
User Options
Format for Better Printing EMail to a Friend Not Available
Admin Print Send ECard
Passions in Poetry

New Cookie Issue

 Post A Reply Post New Topic   Go to the Next Oldest/Previous Topic Return to Topic Page Go to the Next Newest Topic 
Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


0 posted 02-09-2004 01:03 AM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher


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
Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


1 posted 02-09-2004 01:06 AM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

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
Deputy Moderator 10 ToursDeputy Moderator 10 ToursDeputy Moderator 10 ToursDeputy Moderator 10 ToursDeputy Moderator 1 TourDeputy Moderator 1 TourDeputy Moderator 1 Tour
Member Laureate
since 03-07-2001
Posts 19652
British Columbia, Canada


2 posted 02-09-2004 01:30 AM       View Profile for Mysteria   Email Mysteria   Edit/Delete Message      Find Poems  View IP for Mysteria

After reading that I need a coffee and of course, a cookie!
Ron
Administrator
Member Rara Avis
since 05-19-99
Posts 9708
Michigan, US


3 posted 02-09-2004 01:41 AM       View Profile for Ron   Email Ron   Edit/Delete Message      Find Poems   Click to visit Ron's Home Page   View IP for Ron

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 05-19-99
Posts 9708
Michigan, US


4 posted 02-09-2004 01:51 AM       View Profile for Ron   Email Ron   Edit/Delete Message      Find Poems   Click to visit Ron's Home Page   View IP for Ron

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 05-19-99
Posts 9708
Michigan, US


5 posted 02-09-2004 02:04 AM       View Profile for Ron   Email Ron   Edit/Delete Message      Find Poems   Click to visit Ron's Home Page   View IP for Ron

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
Deputy Moderator 1 Tour
Member Empyrean
since 05-18-2001
Posts 29020
Gaia


6 posted 02-09-2004 09:40 AM       View Profile for Midnitesun   Email Midnitesun   Edit/Delete Message      Find Poems  View IP for Midnitesun

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 08-02-99
Posts 9130
Purgatorial Incarceration


7 posted 02-09-2004 12:43 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

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 12-27-2002
Posts 8464
Florida


8 posted 02-09-2004 02:36 PM       View Profile for Susan Caldwell   Edit/Delete Message      Find Poems  View IP for Susan Caldwell

oh my.  

zing, right over my head.

and you know what?

I like it that way.

geez.

Make mine chocolate chip.
Obscurity
Member
since 12-04-2003
Posts 158
In A Melancholic Dream


9 posted 02-11-2004 08:49 AM       View Profile for Obscurity   Email Obscurity   Edit/Delete Message      Find Poems  View IP for Obscurity

Perl, the only language that looks the same before and after it goes through the RSA Algorithm :P
Christopher will be notified of replies
 Post A Reply Post New Topic   Go to the Next Oldest/Previous Topic Return to Topic Page Go to the Next Newest Topic 
All times are ET (US) Top
  User Options
>> Tech Talk >> Beyond the Basics >> New Cookie Issue Format for Better Printing EMail to a Friend Not Available
Print Send ECard

 

pipTalk Home Page | Main Poetry Forums

How to Join | Member's Area / Help | Private Library | Search | Contact Us | Today's Topics | Login
Discussion | Tech Talk | Archives | Sanctuary



© Passions in Poetry and netpoets.com 1998-2013
All Poetry and Prose is copyrighted by the individual authors