The following code works fine in IE8 and Firefox 3.5. Any idea why it does not work in Chrome ? Tried it both in localhost and on my web server -- no success.
In the header:
<?php
if((isset($_COOKIE["unique_id"]))&&isset($_COOKIE["users_resolution"])){
$screen_res = $_COOKIE["users_resolution"];
$unique_id = $_COOKIE["unique_id"];
}
else //means cookie is not found set it using Javascript
{
?>
<script language="javascript">
<!--
writeCookie();
function writeCookie()
{
var today = new Date();
var the_date = new Date("December 31, 2023");
var the_cookie_date = the_date.toGMTString();
var the_cookie = "users_resolution="+ screen.width +"x"+ screen.height;
var the_cookie = "unique_id="+ uniqid();
var the_cookie = the_cookie + ";expires=" + the_cookie_date;
document.cookie=the_cookie
}
function uniqid()
{
var newDate = new Date;
return newDate.getTime();
}
//-->
</script>
<?php } ?>
// And in the ,body>
<?php
echo "Screen resolution: ".$screen_res."<br>";
echo "Unique ID: ".$unique_id."<br>";
?>
Any help would be appreciated.