The most reliable way I can think of to check whether cookies are enabled is to set a cookie in your response from the server in the first place, and check that it's set on the client via document.cookie
. According to this answer to another question, there's no point in checking cookieEnabled
, it doesn't provide correct information.
For instance, if your server includes this header in the response serving the page:
Set-Cookie: cc=1; Max-Age=3600
...then your JavaScript code can check like this:
if (/\bcc=/.test(document.cookie)) {
// They appear to be enabled
} else {
// Not so much
}