<?
if($_SESSION['JSexe']){ //3rd check js
if($_COOKIE['JS']) setcookie('JS','JS',time()-1);//check on every page load
else header('Location: js.html');
} //2nd so far it's been server-side scripting. Client-side scripting must be executed once to set second cookie.
//Without JSexe, user with cookies and js enabled would be sent straight to js.html on first page load.
elseif($_COOKIE['PHP']) $_SESSION['JSexe'] = true;
else{ //1st check cookies
if($_GET['cookie']) header('Location: cookies.html');
else{
setcookie('PHP','PHP');
header('Location: '.$_SERVER['REQUEST_URI'].'?cookie=1');
}
}
?>
<head>
<script type="text/javascript">document.cookie = 'JS=JS'</script>
</head>
I realize this thread is quite old but I wanted to share my script and also see if there is anyone out there with other solutions. It uses PHP, javascript and cookies, and it checks whether cookies and js are enabled or not.
Not sure why the lines are not getting aligned on here, it's more readable and explained on here http://asdlog.com/Check_if_cookies_and_javascript_are_enabled