Guest FeralReason Posted June 11, 2010 Share Posted June 11, 2010 The following code works in IE8 and Firefox 3.5 but not in Chrome. Not sure what I am doing wrong. Does anyone have experience making cookies work with Chrome ? Any help would be appreciated. <html> <head> <title>Cookie Test</title><?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 } ?> </head> <body> <?php echo "Screen resolution: ".$screen_res."<br>"; echo "Unique ID: ".$unique_id."<br>"; ?> </body> </html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.