Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses

Re: cookies n variables

by TexasTess (Beadle)
on Nov 15, 2002 at 12:54 UTC ( #213133=note: print w/replies, xml ) Need Help??

in reply to cookies n variables

I used cookies recently in a project to maintain state and store values between accesses and it worked rather well for me HOWEVER, I found the CGI::Cookie routine to be rather useless for my purposes as it is difficult to mix with other code that is not OO and most of mine was pure long hand. So, if you find that you have problems with the header timing you can use a javascript that writes your cookie in a blank html page that has a refresh rate set to 1. The page is written by the perl script and only appears for a brief second but performs the job marvelously. There are many examples available that illustrate how to break up cookie data easy enough once it's been written in either java or perl so you should not have a problem....
if ($ENV{'HTTP_COOKIE'}) { @cookies = split (/; /, $ENV{'HTTP_COOKIE'}); foreach $cookie (@cookies) { ($name, $value) = split (/=/, $cookie); $cookie_hash{$name} = $value; } }
Google it, you'll find a ton of examples...

"Great Spirits Often Encounter Violent Opposition From Mediocre Minds" --Albert Einstein

Replies are listed 'Best First'.
Re: Re: cookies n variables
by thraxil (Prior) on Nov 15, 2002 at 16:46 UTC

    how, exactly, is difficult to use with non-OO code? that doesn't make any sense to me.

    what is the problem you are referring to with header timing? i've been doing CGI programming and using cookies for years now and have never encountered a problem like that.

    finally, i really would strongly recommend not trying to reinvent the wheel and write your own cookie parser. does the job just fine and should be easier to read. see use CGI or die; for more on that.

    anders pearson

Re: Re: cookies n variables
by CukiMnstr (Deacon) on Nov 15, 2002 at 18:38 UTC

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://213133]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (4)
As of 2023-09-30 13:48 GMT
Find Nodes?
    Voting Booth?

    No recent polls found