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
 More Cookie Help
 1 2 3 4 5 6 7
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

More Cookie Help (Why Doubling?)

 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-16-2004 10:06 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

Trying to figure out a "good" way to explain this. I'm cool on the setting and retreiving bit, but having some problems clearing the cookies... well, kind of. I seem to be able to clear them fine, but they also seem to be doubling - I end up with

owner@www.egowhores[1].txt

and

owner@egowhores[1].txt

which the program appears to be reading as two separate cookies. The thing is, I have no idea HOW I'm creating two sets of cookies.

Needless to say, this is causing a bit of a problem with clearing them.

Any help would be appreciated.

And here's the cookie-call for what it's worth:




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 = "Wed, 23-Feb-2005 00:00:00 GMT";
        print qq~Set-Cookie: egowhores=$value;expires=$Expires;path=/;\n~;
        undef %cookie;
    }
}
Ron
Administrator
Member Rara Avis
since 05-19-99
Posts 9708
Michigan, US


1 posted 02-17-2004 06:37 AM       View Profile for Ron   Email Ron   Edit/Delete Message      Find Poems   Click to visit Ron's Home Page   View IP for Ron

quote:
I end up with

owner@www.egowhores[1].txt

and

owner@egowhores[1].txt

which the program appears to be reading as two separate cookies.

I'm guessing those are coming from outside your script, Chris? From examining the disk for cookies?

Bottom line is that they ARE two separate cookies, or at least should be, depending on your server configuration at the Apache level. If you read the Help files I've written here for cookies, one of the warnings I issue is to never use our www.piptalk.com domain, because it is NOT the same as piptalk.com as far as cookies are concerned. All of our URLs in the forums very carefully avoid the www prefix for that very reason. Cookies are domain dependent (more or less).

Pick one domain and stick to it. Your program should never run on the other.


quote:
I end up with

owner@www.egowhores[1].txt

and

owner@egowhores[1].txt

which the program appears to be reading as two separate cookies.

I'm guessing those are coming from outside your script, Chris? From examining the disk for cookies?

Bottom line is that they ARE two separate cookies, or at least should be, depending on your server configuration at the Apache level. If you read the Help files I've written here for cookies, one of the warnings I issue is to never use our www.piptalk.com domain, because it is NOT the same as piptalk.com as far as cookies are concerned. All of our URLs in the forums very carefully avoid the www prefix for that very reason. Cookies are domain dependent (more or less).

Pick one domain and stick to it. Your program should never run on the other.


Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


2 posted 02-17-2004 01:06 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

see, it even doubled your post, Ron.

I understand what you're saying... with the exception of HOW i'm arriving at this duplicate. I don't believe (though I will double-check tonight) that i'm entering the page differently...

Thank you for your response.

Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


3 posted 02-17-2004 01:07 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

And yes, those are coming from examining my cookies - they are the file handles in my "cookies" section on the hard disk.
Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


4 posted 02-17-2004 10:35 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

Now that I'm home and can look at what was happening - I understand fully... is there no way then to cover both eventualities? i'm guessing not, since they will be seen as cookies from two different sites.

bummer. thanks again Ron.

C
Ron
Administrator
Member Rara Avis
since 05-19-99
Posts 9708
Michigan, US


5 posted 02-18-2004 08:10 PM       View Profile for Ron   Email Ron   Edit/Delete Message      Find Poems   Click to visit Ron's Home Page   View IP for Ron

quote:
... is there no way then to cover both eventualities?


Actually, there is, at least two that I know (now).

http://poetry-web.com/

Click on the above link and then look at your Address/Location bar. This is the result of an Apache configuration command (see RedirectPermanent ) placed in httpd.conf on the server. It is activated way before any page or Perl code can be called, making it impossible to create cookies for the base domain 'cause ya can't get there from here (or any where else).

The benefits to this solution go well beyond cookies. Most of the search engines, and especially Google, count links to your web site as "votes" from outside parties. If you have 1,000 links to your site and I have only 500 to mine, Google figures your site is "better" than my site. All other things being equal (though they never are), your site will rank much higher in a search than will mine. The problem arises when your 1,000 inbound links are split and my 500 aren't. You have 500 links to domain.com, 500 links to www.domain..com, thus making each equivalent to my 500 links. Your "votes" have been diluted by inconsistent linking, so you don't get all the benefits from them that you could.

When Google encounters a RedirectPermanent (often called a 301), it realizes the two domains should be considered the same and combines all their votes.

The disadvantage to this solution is that it's pretty low level and won't be available to everyone. If you're on a shared server, the only way to implement it is to talk your hosting company into making the changes for you. Frankly, most hosting companies won't know enough about Apache to even know what you want.

So, here's an alternative solution that should work for you. I haven't tested it, so would appreciate your feedback on the results.

Change every instance of this:

print qq~Set-Cookie: egowhores=$value;expires=$Expires;path=/;\n~;

to this:

print qq~Set-Cookie: egowhores=$value;expires=$Expires;domain=. egowhores.com;path=/;\n~;

Please note that .egowhores.com has TWO periods, and could probably be read as *.egowhores.com to be more intuitive. This "should" make your cookies work across all subdomains, including www. Let me know if it does?


Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


6 posted 02-18-2004 09:30 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

Of course I will!
Christopher
Moderator
Member Rara Avis
since 08-02-99
Posts 9130
Purgatorial Incarceration


7 posted 02-19-2004 10:05 PM       View Profile for Christopher   Email Christopher   Edit/Delete Message      Find Poems  View IP for Christopher

Worked beautifully.

I did have to go back and remove the space between the period prior to "egowhores", however. I'd noticed it earlier when i first looked at this, but forgot until it didn't work.

I tried logging in and out with sans and with www.,  worked fine, mixed it up a both and seems to be working great. It just changes the number in brackets, ie: owner@egowhores.com[1], but isn't creating a separate cookie.

Sweetness from the smart man.  
 
 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 >> More Cookie Help 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