Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Qustion about 'web browser' identification (mobile) (http://www.go4expert.com/forums/qustion-web-browser-identification-t6633/)

standard240 1Oct2007 02:17

Qustion about 'web browser' identification (mobile)
 
Hi,
I was wondering if anyone could tell me how exactly a website knows if you are visiting from your computer (ie/firefox) or from your cell phone browser???

For example, if I go to http://mobile.google.com in firefox, it is a different webpage than if I use my mobile browser.

I just need to know how it works, or how I can access the mobile version of a webpage on my PC?

Any info will help!

shabbir 1Oct2007 04:41

Re: Qustion about 'web browser' identification (mobile)
 
It totally depends on how the web site owner has setup his website. Lets say you are a site owner and when you detect a mobile web browser you redirect them to page a and when its PC user you redirect them to page b. Now by no means when you are at your PC you can view the page a because it will redirect you to page b and vice versa.

Now I think there should be a way to fool the coding out there but for that you should be doing some RnD.

First have a website page where you can get the details about your mobile page like browser type / OS. Now using the Firefox browser agent have your details as if you are on mobile and try browsing the website using that agent and you may have some success but I am not sure about it.

pete_bisby 5Dec2007 01:01

Re: Qustion about 'web browser' identification (mobile)
 
Use the phpinfo() function to return all of the variables associated with PHP. Towards the end of the page that has loaded within your web browser you will see the _SERVER variables. One of these variables, _SERVER["HTTP_USER_AGENT"], will return the description of the web browser you are using (I've omitted the dollar sign in front of the _SERVER, just in case it plays havoc with the forum !!)

As a quick test, using IE6, the server variable returns "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; www.lifetranslator.biz; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)".

Using Firefox returns "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.1.9) Gecko/20071025 Firefox/2.0.0.9".

(tested on Windows XP Professional platform, using Apache Web Server)

Now if you create a simple index.php page and use a switch statement looking for specific information within the _SERVER["HTTP_USER_AGENT"] variable, you will be able to redirect web browsers on different platforms to the correct code pages.


All times are GMT +5.5. The time now is 10:45.