Darkmatter5 Posted November 11, 2008 Share Posted November 11, 2008 Here's my code <?php if(isset($HTTP_COOKIE_VARS["resolution"])) { $screen_res=$HTTP_COOKIE_VARS["resolution"]; } else { ?> <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="resolution="+ screen.width +"x"+ screen.height; var the_cookie=the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location='gateway.php'; } //--> </script> <?php } ?> The location command doesn't forward me to the gateway.php page. Why not? Quote Link to comment Share on other sites More sharing options...
rhodesa Posted November 11, 2008 Share Posted November 11, 2008 window.location.href = 'gateway.php'; or window.location.replace('gateway.php'); Quote Link to comment Share on other sites More sharing options...
Darkmatter5 Posted November 11, 2008 Author Share Posted November 11, 2008 It actually was working except, that the php at the top of the code that checked for $HTTP_COOKIE_VARS["resolution"] was set, wasn't doing anythign except setting a variable to be the cookie. I changed the code to be the following and it works like a charm, but if the user changes the resolution while viewing the site and don't clear their cookies it'll use their old resolution. <?php if(isset($HTTP_COOKIE_VARS["resolution"])) { header("Location: gateway.php"); } else { ?> <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="resolution="+ screen.width +"x"+ screen.height; var the_cookie=the_cookie + ";expires=" + the_cookie_date; document.cookie=the_cookie location='gateway.php'; } //--> </script> <?php } ?> Thanks for the help! Quote Link to comment Share on other sites More sharing options...
BoltZ Posted November 12, 2008 Share Posted November 12, 2008 Also the language is depreciated in JS. Use <script type="text/javascript"> Sigh Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.