In case you care about screen size you can store screen width and Height as cookie values if they do not exists yet and then make self page redirection.
Now you have cookies on client and server side and can use it to determine mobile phones, tablets and other devices
Here a quick example how you can do it with JavaScript. Warning! [this code contain pseudo code].
if (!getcookie("screen_size")) {
var screen_width = screen.width;
var screen_height = screen.height;
setcookie("screen_size", screen_width+", " +screen_height);
go2(geturl());
}