PCHomepage
Programmer
I know that PHP cannot fetch the screen size but using a bit of JavaScript to write a cookie, it gave me a value with which to start. However, I must have missed something because I can't get the session written! Does anyone see what's wrong? I use sessions all the time and sessions themselves are indeed being written as there are other values in use so clearly I've made a mistake that I can't spot.
For reference, the JavaScript, which is working and is providing the cookie value, has simply:
PHP:
function Resolution() {
if (isset($_SESSION['screen_width'])) :
return $_SESSION['screen_width'];
elseif (isset($_REQUEST['width'])) :
$_SESSION['screen_width'] = $_REQUEST['width'];
return $_SESSION['screen_width'];
elseif (isset($_COOKIE['size'])) :
$_SESSION['screen_width'] = $_COOKIE['size'];
return $_SESSION['screen_width'];
else :
return "";
endif;
}
For reference, the JavaScript, which is working and is providing the cookie value, has simply:
JavaScript:
var c=document.cookie;
document.cookie='size='+Math.max(screen.width,screen.height)+';';