Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Loging a user out with CGI and Cookies?

by merlyn (Sage)
on Apr 16, 2001 at 15:52 UTC ( #72805=note: print w/replies, xml ) Need Help??


in reply to Loging a user out with CGI and Cookies?

You should definitely read my article on branding a browser with a cookie.

In there, I say something like: do not use the presence of a cookie to indicate a logged-in state, because the browser is free to ignore your requests to remove the cookie or expire it after a while.

Instead, simply ignore that particular cookie if it's sent in the future. This means you should use a cookie only as a key to a server-side database which shows the current state of logged-in or not.

-- Randal L. Schwartz, Perl hacker

  • Comment on Re: Loging a user out with CGI and Cookies?

Replies are listed 'Best First'.
Re: Re: Loging a user out with CGI and Cookies?
by LiTinOveWeedle (Scribe) on Apr 17, 2001 at 02:50 UTC
    Hi Merlyn,
    maybe I am wrong but I thing that there is litle mistake in your code. Line 34:

    my $cache = File::Cache->;new({namespace => 'cookiemaker',

    Should be without ";":

    my $cache = File::Cache->new({namespace => 'cookiemaker',

    This probabably happened by copying line 33.

    Your servant Li Tin O've Weedle
    mad Tsort's philosopher

      That's an artifact (read: "bug") from pod2html, which is why I also provide the companion colNN.listing.txt file in the same directory.

      -- Randal L. Schwartz, Perl hacker

Re: Re: Loging a user out with CGI and Cookies?
by r.joseph (Hermit) on Apr 16, 2001 at 19:34 UTC
    Thanks merlyn - shortly after posting this, I broke out the latest "Web Techbniques" and re-read your article a couple times. Your right - as I was testing new ideas, I noticed that sometimes my browser did in fact ignore the cookie expiry all together. Therefore, I am going to need to implement some type of server side session info, has had been previously suggested.

    Thanks for all the help!

    r. j o s e p h
    "Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov
      Merlyn was right again,
      but should be interesting to know which one browser has problems..... Microsoft Internet Exploder? Netsuck?
      I am using MSIE 5.0 (PC) and I founded some diferencies between PC and Mac version - right with cookie and redirect operations.

      THX

      Li Tin O've Weedle
      mad Tsort's philosopher

        I had some problems with an older version of MSIE, but I don't remember which version. However, I found out that on IE for Mac (the latest version, 4 something I think) the browser didn't even store my cookie in the first play, which was very disconcerting because that means that the login didn't work in that browser. Very odd problem, although that was the only case in which I have had that problem.

        r. j o s e p h
        "Violence is a last resort of the incompetent" - Salvor Hardin, Foundation by Issac Asimov

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2021-10-28 09:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (96 votes). Check out past polls.

    Notices?