Getting screen resolution of visitor in php

Hi

I get visitors to my file process.php where I get all details of visitor and do different checks and then redirect visitor to different external pages.

I am trying to trace screen resolution of visitor by following code in php file. I tried to store screen resolution in cookie and then get cookie data in php file.

<? if($_COOKIE["screenres"]=="" or !isset($_COOKIE["screenres"])) header("Refresh:0"); $screenres = $_COOKIE["screenres"]; ?>

Any help or better way to get screen resolution in php. I don’t want java redirect method to avoid http_referrer url creation. I don’t want that my site link pass to external pages if I try redirect method.


Any help or better way to get screen resolution in php. I don’t want java redirect method to avoid http_referrer url creation. I don’t want that my site link pass to external pages if I try redirect method.

How are you getting the resolution now, and why does it matter?

PHP doesn’t know anything about the user or their screen resolution. That is javascripts job. Now, you could make an ajax call when the page loads and have that resolution sent back to php, but other than that, php doesn’t have a way of knowing unless it gets sent the data and even then, it is data nothing more.

@ [astonecipher] Thanks for replying.

Actually I posted javascript code in my post but that was not displayed. Anyhow I do this again in details.

Instead of old cookie method I tried 2 different methods and both work in test mode but when I apply same code LIVE then instead of saving variable value in database, javascript code is being stored in database.


When i created simple php file and opened in browser both codes show correct screen resolution but when I try to save $screenres value in database then javascript code in variable is saved.

Sponsor our Newsletter | Privacy Policy | Terms of Service