Skip to content

Instantly share code, notes, and snippets.

@SecureCloud-biz
Created July 12, 2014 23:03
Show Gist options
  • Save SecureCloud-biz/0132bcf7ab9c0180d6bf to your computer and use it in GitHub Desktop.
Save SecureCloud-biz/0132bcf7ab9c0180d6bf to your computer and use it in GitHub Desktop.
PHP_screen_resolution
<?php
session_start();
if (isset($_SESSION['screen_width']) AND isset($_SESSION['screen_height'])) {
echo 'User resolution: ' . $_SESSION['screen_width'] . 'x' . $_SESSION['screen_height'];
} else if(isset($_REQUEST['width']) AND isset($_REQUEST['height'])) {
$_SESSION['screen_width'] = $_REQUEST['width'];
$_SESSION['screen_height'] = $_REQUEST['height'];
header('Location: ' . $_SERVER['PHP_SELF']);
} else {
echo '<script type="text/javascript">window.location = "' . $_SERVER['PHP_SELF'] . '?width="+screen.width+"&height="+screen.height;</script>';
}
/* returns => 1600x900 */
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment