NYCPHP Meetup

NYPHP.org

[nycphp-talk] screen resolution redirection with php

Henry Ponce henry at beewh.com
Fri Aug 5 15:04:22 EDT 2005


Hi all:

I'm looking for a solution to my problem or if anybody can point me in the 
right direction so I can figure it out on my own.

Here's the situation:
I want to know what screen resolution a user is using. I found that this can 
be done with javascript. I found this function that does this and 
redirects...

function redirectPage() {
var url640x480 = "http://www.yoursite.com/640x480";
var url800x600 = "http://www.yoursite.com/800x600";
var url1024x768 = "http://www.yoursite.com/1024x768";
if ((screen.width == 640) && (screen.height == 480)) 
window.location.href= url640x480;
else if ((screen.width == 800) && (screen.height == 600))
window.location.href= url800x600;
else if ((screen.width == 1024) && (screen.height == 768))
window.location.href= url1024x768;
else window.location.href= url640x480;
}


But i dont want this...i want to save in a cookie or $_SESSION variable the 
resolution info and based on that use one css, or another, use an include or 
not. etc...

How can i handle this with php? is there a way? or am I stuck with javascript 
(which i know that is not 100% solution, since a user can turn off in 
browser), but in that case i can create a default design, css, etc for those 
cases.

I was thinking of creating a cookie with javascript and then accessing that 
cookie with a php code. Just a thought....

Can anyone help me, point me in the right direction or share how you solved 
this issue?

Henry



More information about the talk mailing list