Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Server getting and utilizing cookie

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


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 08: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 06, 2001 at 00: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
Node Status?
node history
Node Type: note [id://61733]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (7)
As of 2020-08-07 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which rocket would you take to Mars?










    Results (45 votes). Check out past polls.

    Notices?