We help IT Professionals succeed at work.

iPad device registers as Mac

Richard Korts
on
65 Views
Last Modified: 2020-04-21
I have a php program that uses $_SERVER['HTTP_USER_AGENT'] to determine the device type.

A user claims they are using an iPad, they get the attached (I just echoed the result of $_SERVER['HTTP_USER_AGENT'] on the server).

Why does this occur?
ipad_says_mac.jpg
Comment
Watch Question

Dr. KlahnPrincipal Software Engineer
CERTIFIED EXPERT

Commented:
iphones identify as such, but it looks like this ipad identifies itself as a mac.  

whatismybrowser indicates that an ipad should identify itself as such early on in the ident string.  The ident being supplied by the ipad does not resemble those listed by whatismybrowser.  Possibly a browser spoofing plugin in the ipad's browser?

https://developers.whatismybrowser.com/useragents/explore/operating_platform/ipad/

e.g., Mozilla/5.0 (iPad; CPU OS 12_4_5 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/12.1.2 Mobile/15E148 Safari/604.1
David FavorFractional CTO
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
This occurs because you're using an Apple Browser which leverages the WebKit libraries...
_______

Every browser + many other software tools provide a HTTP_USER_AGENT which should always be treated as bogus.

All Apple browsers (not devices) return an AppleWebKit user agent string + can also return other strings... depending on the purpose of the tool.

If you run PhantomJS on a Linux or Windows machine, you'll still see HTTP_USER_AGENT containing AppleWebKit, because PhantomJS uses the WebKit libraries.

The way to think about this is the HTTP_USER_AGENT provides a hint of the browser running on the other end, not anything about the device hardware.

Also be sure your treat HTTP_USER_AGENT as a hint, because this string is trivial to forge.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
On my iPad, doing exactly the same thing, it says: Mozilla/5.0 (iPad; CPU OS_12_4_5 like Mac OS X), AppleWebKit/605.1.15 etc.

My simple minded read of this is that the iPad returning a Mac designation has an older version of the Mac OS (10 something instead of 12 something).

Is there any way of detecting the device?

Thanks
Simple Geek from the '70s
CERTIFIED EXPERT
Distinguished Expert 2019
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
OK, so there is no way to detect the device in php.

Correct?

Thanks
David Johnson, CDSimple Geek from the '70s
CERTIFIED EXPERT
Distinguished Expert 2019

Commented:
did you not see the different version numbers after webkit/


This problem is over a year old, Apple knew about it in the beta stage and ignored it.
Dr. KlahnPrincipal Software Engineer
CERTIFIED EXPERT

Commented:
As David says, the user-agent string is not something to be safely relied upon for anything important.

If there is some critical issue that requires knowing when an ipad is on the requesting end, you could profile the display and look at the installed fonts -- but it seems like a lot of work to prevent somebody from seeing a display which was not intended to be seen on a tiny screen.  Caveat lector is a more practical policy there.
Richard KortsBusiness Owner / Chief Developer

Author

Commented:
David Johnson,

I get your point, assuming it "sticks". 'll try the webkit number ID, see where that goes.

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.