how do I know if cookies are enabled?

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hi Gurus

What is the most reliable and efficient way to find out if the user has  
cookies enabled? I know this is a really stupid question, but I can't seem  
to work it out.

Re: how do I know if cookies are enabled?

While I would first suggest that you design your pages where cookies
aren't required, the simplest way would be to include a small cookie
(hascookies=true, for example) on index.php then send a redirect header
to index2.php (or whatever) that checks for the existence of the
hascookies cookie. Then just design your site around index2.php instead
of index.php.

(if that seems sloppy, you could set the defaultindex in apache to
cookietest.php or something then redirect to index.php)

Hope that works for you.

Re: how do I know if cookies are enabled?

from windandwaves contained the following:

Quoted text here. Click to load it

The thing is, its a two hit deal.  When the user visits your page your
page can set a cookie on the users machine.  But you only get to find
out if the cookie was set on the next server call, when the cookie is
sent back.
Geoff Berrow (put thecat out to email)
It's only Usenet, no one dies.
My opinions, not the committee's, mine.
Simple RFDs

Site Timeline