Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

How can you tell if cookies are disabled?

by Anonymous Monk
on Mar 28, 2002 at 11:37 UTC ( [id://154925]=perlquestion: print w/replies, xml ) Need Help??

Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Is there a way to tell that the user has disabled cookies or has set the privacy rating too high? I want to print a special message if that happens.
  • Comment on How can you tell if cookies are disabled?

Replies are listed 'Best First'.
Re: How can you tell if cookies are disabled?
by Kanji (Parson) on Mar 28, 2002 at 12:04 UTC
      Quote from article:
      The wrong way to use cookies, therefore, is to have a login form, and on successful login, send out a cookie that lasts until year 2003 to that browser. That's bad. I can't login on another browser, and if I forget to logout of a browser at an ``internet cafe'', the next user who stumbles across the same website is (gasp!) already logged in as me!

      Erm like Perlmonks does :-}
      What we have here of course is a trade off between security and usability. The most secure access is lock the machine in a safe, and bury it in concrete, but thats not very usable. Whilst semi-permanent cookies for login control are less secure in the arena of something like perlmonks its less of an issue than say your online internet bank account :)

      ---If it doesn't fit use a bigger hammer
        Many sites have checkbox 'Remember me' in their login form which affects cookie lifetime (i.e. cookie lasts only for browser session or cookie will be expired in next several years). Perlmonks is not exception.

        I think it is quite reasonable approach. I have this checkbox checked when I visit perlmonks from home and I don't check it when I visit perlmonks from other places.

        --
        Ilya Martynov (http://martynov.org/)

Re: How can you tell if cookies are disabled?
by projekt21 (Friar) on Mar 28, 2002 at 11:45 UTC

    I don't know of another way than setting the cookie and then reading it again to check if it's present.

    alex pleiner <alex@zeitform.de>
    zeitform Internet Dienste

      projekt21 is right. The client server relationship between the web browser and the server consists of the browser contacting the server and requesting a page. The request for the page will include any relevent cookies (ie ones that match the domain). So you need to set a cookie in your response and then if you dont recieve the cookie next time the browser makes a request assume that cookies are disabled
      You may be able to get some javascript to detect the state of cookies and then adjust any furtehr requests to say "I dont do cookies" (a cookies=no parameter in a hidden form) but it will still be a two stage process of you sending a page with the javascript in first and waiting for the next page that the browser requests.

      ---If it doesn't fit use a bigger hammer

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-04-24 09:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found