From: FAQ server on
-----------------------------------------------------------------------
FAQ Topic - How can I see in javascript if a web browser
accepts cookies?
-----------------------------------------------------------------------

Write a cookie and read it back and check if it's the same.

Additional Notes:

http://www.ietf.org/rfc/rfc2965.txt

http://www.galasoft-lb.ch/myjavascript/consulting/2001012701/

http://www.cookiecentral.com/


The complete comp.lang.javascript FAQ is at
http://jibbering.com/faq/

--

The sendings of these daily posts are proficiently hosted
by http://www.pair.com.

From: Joe Nine on
Andrew Poulos wrote:
> On 16/06/2010 9:00 AM, FAQ server wrote:
> Is the cookieEnabled property proprietary or unreliable?
>
> Andrew Poulos

All the major browsers apparently support it:
http://www.w3schools.com/jsref/prop_nav_cookieenabled.asp
From: VK on
On Jun 16, 12:09 pm, Joe Nine <j...(a)yahoo.com> wrote:
> Joe Nine wrote:
> > Andrew Poulos wrote:
> >> On 16/06/2010 9:00 AM, FAQ server wrote:
> >> Is the cookieEnabled property proprietary or unreliable?
>
> >> Andrew Poulos
>
> > All the major browsers apparently support it:
> >http://www.w3schools.com/jsref/prop_nav_cookieenabled.asp
>
> It would have been useful if they said from which version of each of the
> major browsers it was supported. It's not useful if it was for example
> in IE only since version 8, or in Firefox only since version 3.6. But if
> it's been in all the major browsers since 1999 then that's a lot more
> useful.

window.navigator.cookieEnabled read-only flag originally is IE
proprietary extension available since at least IE6. Many others
adopted it as well during the past 3-6 years. Yet the Gecko
implementation has the bug # 230350
https://developer.mozilla.org/En/Navigator.cookieEnabled
https://bugzilla.mozilla.org/show_bug.cgi?id=230350
That makes cookieEnabled pretty much useless on Gecko platforms as it
only tells you if system-wide cookie accept option is on or off,
irrespectively to per domain exceptions. It is very seldom what you
want to know. Most of the time you need to know if client-side
persistent cookies are enabled for that particular (sub)domain, so the
FAQ answer remains the most reliable option.


http://msdn.microsoft.com/en-us/library/ms533694%28VS.85%29.aspx
From: Richard Cornford on
On Jun 16, 1:15 am, Andrew Poulos wrote:
> On 16/06/2010 9:00 AM, FAQ server wrote:
>> -----------------------------------------------------------
>> FAQ Topic - How can I see in javascript if a web browser
>> accepts cookies?
>> -----------------------------------------------------------
>
>> Write a cookie and read it back and check if it's the same.
<snip>
>
> Is the cookieEnabled property proprietary or unreliable?

Even if reliable/universal any - cookieEnabled - property could only
tell you about what the browser thinks the situation is. It may not
(be able to) tell you about the influence of local (and local-ish)
proxies (which probably includes all of the 'Internet security'
programs). Proxies may not wish to pass on (probably only particular
types of) cookie, which would certainly impact on their usefulness.

There were (and so may still be) content-inserting/re-writing proxies
that would specifically target the ability of client-side code to
manipulate cookies by scanning code passing through them and replacing
the Identifier 'cookie' with some other sequence of characters. (There
were examples of the over zealous application of this transformation
impacting web documentation, on cookies and probably cooking.) In the
presence of such proxies simply writing a cookie and reading it back
to see if it is the same will not be sufficient (as that would just
create an expando (with the alternative Identifier) by assigning a
value and then recover its value, which would be expected to be the
same). It is a good idea to verify the type of - document.cookie -
prior to using it, as if it is not a string then it is also non-
viable.

Richard.