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

Re: Server getting and utilizing cookie

by dvergin (Monsignor)
on Mar 02, 2001 at 01:41 UTC ( [id://61733]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Server getting and utilizing cookie

You still need a way to tell if the client is not accepting cookies. Otherwise you just keep making cookies and coming back to discover that the client needs a cookie. Here's the logic I'd use (in pseudo-code obviously):
if $cookie = $cgi->cookie("Whatever") check to see if it meets our standards do business #elsif $cgi->cookie("CookieTest") ## Oops! mistyped... elsif $cgi->param("CookieTest") ## Corrected #we tried to set a cookie and failed bailout else set the cookie set a http location: header line that includes: the url by which we arrived here + CookieTest=1 in the query string clean up and exit end
More questions? Just ask...

Replies are listed 'Best First'.
Re: Re: Server getting and utilizing cookie
by sutch (Curate) on Mar 02, 2001 at 03:13 UTC
    This is close to what I have done for testing for users/browsers acceptance of cookies. Instead of using a test cookie though, directly set the necessary cookie and pass a query string in the redirect. I have run into situations where a user may accept one cookie but not the next!

    Modifying dvergin's pseudo-code:

    if $cookie = $cgi->cookie("CookieName") check to see if it meets our standards do business else if $cgi->param("TestingCookie") # no need to test value #we tried to set a cookie and failed bailout # or notify user of cookie failure and continue set the cookie set a http location: header line that includes: the url by which we arrived here + CookieName=value in the query string + a query string TestingCookie=1 clean up and exit end
      Good catch sutch. I puzzled over your comments until I realized that I had mis-typed. The line in my post should, of course, be:
      elsif $cgi->param("CookieTest") not elsif $cgi->cookie("CookieTest")
      And with that, I think our solutions are substantially the same.
Re: Re: Server getting and utilizing cookie
by Hammy (Scribe) on Mar 05, 2001 at 19:18 UTC
    I implemented that solution (sort of) and I continually set the cookie everytime through the loop. I guess I don't quite get the "set the http location...." piece. My cookie must never get set. Any advice?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://61733]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.