I was researching about how to check if the cookies are enabled in a browser and i found a lot of answer, i even tested a few ones, but after that a friend of mine
A direct answer to the question is 'Yes!' and it is built in
Example code:
if (Modernizr.cookies == false) {
alert('Please enable cookies');
}
else {
// do something with cookies
}
You can also use the css class .cookies
or .no-cookies
to show/hide a panel telling the user they need cookies enabled.
.cookies #noCookies
{
display: none;
}
This site requires cookies! Please turn them on already!
(This .cookies
class is added to tag by Modernizr).
Note: If you are creating a custom build of Modernizr the cookies
option is currently 'hidden' under the 'Non-core detects' section.