PHP Code:
if (!isset($_COOKIE['cookies_enabled']) && !isset($_GET['cookie_test'])) {
// lets set a cookie and try again
setcookie('cookies_enabled', '1');
header('Location: ' . $_SERVER['PHP_SELF'] . '?cookie_test');
exit;
} elseif (!isset($_COOKIE['cookies_enabled']) && isset($_GET['cookie_test'])) {
// we already tried, but they didnt accept our cookie
// do something
} else {
// they accepted out cookie
}
you need to be careful when doing things like that though. if you included that code in every page its going to cause a lot of redirects for those with cookies disabled unless your make sure to carry ?cookie_test along all the urls in your website.
Bookmarks