The best possible solution is
<script language="javascript">
if (window.location.search == "") {
window.location.href = window.location + "?width=" + screen.width + "&height=" + screen.height;
}
</script>
Then create a file called screen.php and use this:
<?php
$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
http://www.webmasterworld.com/forum88/4700.htm