Answer the question
In order to leave comments, you need to log in
Answer the question
In order to leave comments, you need to log in
This is easier to do in javascript.
For new browsers:
For old ones:if (navigator.cookieEnabled) return true;
// set and read cookie
document.cookie = "cookietest=1";
var ret = document.cookie.indexOf("cookietest=") != -1;
// delete cookie
document.cookie = "cookietest=1; expires=Thu, 01-Jan-1970 00:00:01 GMT";
return ret;
<?php
session_start();
setcookie('foo', 'bar', time()+3600);
header("location: check.php");
<?php echo (isset($_COOKIE['foo']) && $_COOKIE['foo']=='bar') ? 'enabled' : 'disabled';
In 2 requests to the server
1. set the cookie
2. check whether it exists or not
In the first request, the cookie is only sent to the client, so until the next one we do not know whether the cookie was stored on the client or not.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question