Find Screen Resolution With PHP

by Hiroshi on August 7, 2008

in Checks, Cookies, Tricks, Useful Scripts

I think there is no way yet to find out screen resolution with PHP. hehehe.
If I am wrong please correct me.
But yet we can trick it to be happen ;-)
If not then how can we be developers. Right!

With javascript we find out screen resolution of PC. Store it in a cookie and display it with PHP.
Coool…eh! Fine, lets just do it.

<script LANGUAGE="javascript">
width = screen.width;
height = screen.height;
document.write("<b>You're set to "+width+ "X" +height+"</b>")
echo $yo;

For head section of webpage.

$screen_res = $HTTP_COOKIE_VARS["users_resolution"];
else //means cookie is not found set it using Javascript
<script language="javascript">
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 = the_cookie + ";expires=" + the_cookie_date;
location = 'screen.php';

Body section of webpage. Display the screen resolution.

echo "Your screen resolution is set at ". $screen_res;

Enjoy!!! …Chill Pill…

Download Script

Related Posts

Previous post:

Next post: