Get Screen resolution of User in PHP

coderzone's Avatar, Join Date: Jul 2004
Team Leader
Is there any way to know the User Screen Resolution in PHP.

I am not sure if it can be done also,
onlyani's Avatar
Newbie Member
The pages you make (as php developer) could
use client-side javascript to detect the local
screen resolution. Then, theoretically, you could
send an Ajax message back to the server, to set
a session variable, so all subsequent requests
could be either dynamically generated, with differing
image sizes, or you could, maybe, use url-rewriting
to redirect to the right static html (with differing
image sizes).

But that's got a hidden catch22. Because the 37% of
all users who still use 800x600 resolution probably won't
have browsers that can deal with Ajax requests.

Has anybody ever figured out how to optimize image
sizes for different screen resolutions?
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
The best possible solution is

<script language="javascript">
if ( == "") {
window.location.href = window.location + "?width=" + screen.width + "&height=" + screen.height;

Then create a file called screen.php and use this:

$width = $_get['width'];
$height = $_get['height'];

echo "You are using a $width x $height screen resolution";
// And set them into cookies as well.

You can also look into