I'm looking for some code that will return me values if the user has JavaScript enabled or disabled, as well as cookies.
I know this is probably easy to do, but my time limits are so tight that it hurts. There must be something using php that does this. Ideally, I would like to find code that has a page setup with all the possible values that could affect my scripts.
EDIT: Obviously, JavaScript may be disabled, but I hope I can find something there to test these two cases.
My decision
For an anonymous code search, to determine if cookies are enabled or disabled, this is what I came up with from the posts below ... you can simply discard this to the top of any page, and it works ...
<?php
if (!isset($_SESSION['cookie_check']))
{
if (!isset($_GET['cc']))
{
setcookie("cookiecheck", "ok", time()+3600);
header("Location: ".$common->selfURL()."?cc=1");
exit(0);
}
else
{
if (@$_COOKIE['cookiecheck'] != "ok")
{
header("Location: /site-diag.php");
exit(0);
}
else
{
$_SESSION['cookie_check'] = true;
}
}
}
?>
source
share