How do I detect mobile clients on my web server?
26,455
Solution 1
You can grab the User Agent. That tells what browser type it is (iphone, chrome, ie, anything)
To help you:
http://en.wikipedia.org/wiki/User_agent
Solution 2
You need to check the header of the HTTP request. You can find both the OS and the browser being used in the "User-Agent" field.
If you are using javascript then use the navigator
object
navigator.userAgent
If you are using php then you can access the HTTP header
$userAgent = $_SERVER["HTTP_USER_AGENT"];
Author by
shebelaw
Updated on July 09, 2022Comments
-
shebelaw almost 2 years
When http request comes to my server, how do I detect if it is from iphone, android, or other devices?
-
ceejayoz about 13 yearsDo note that this is easily faked.
-
Pepe about 13 years@ceejayoz Yes of course. But I don't see any issues arising from that since the users would prob want the best experience and layout that fits the actual client being used. So they don't really have any interest in doing that.
-
Pepe about 13 years@ceejayoz Also I don't think the OP can do anything to prevent that on his end...
-
ceejayoz about 13 yearsAgreed. Just worth noting, as I've seen people try to restrict access in this manner and be surprised that it won't work for determined users.
-
shebelaw about 13 yearsIn the case of iPhone can I also get ESN, IME ID of the phone using JavaScript?
-
Pepe about 13 years@user736659 I don't think so.
-
Shadow The Kid Wizard over 11 years@JJPA true, offender is now suspended and the illegal answers deleted.
-
Shadow The Kid Wizard over 11 years@JJPA not my doing, just reporting it to prevent the author here from getting confused when the link you posted does not give him the answer you meant to show..