Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to detect windows 11 from user agent?

How I can figure out if someone opens my website in windows 11?

I test user agent and when someone opens my website with windows 11 I will get this

"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0"

So technically this says it's windows 10, not 11.

Is there any way to detect this?

like image 903
Ali Akbar Azizi Avatar asked Aug 01 '21 21:08

Ali Akbar Azizi


People also ask

What does the user agent tell you?

The User-Agent tells the server what the visiting device is (among many other things) and this information can be used to determine what content to return. Of course this requires using a device detection solution which translates UAs into understandable software and hardware information.

How do I access user agent?

Google Chrome Chrome's user agent switcher is part of its Developer Tools. Open them by clicking the menu button and selecting More Tools > Developer Tools. You can also use press Ctrl+Shift+I on your keyboard.


1 Answers

Using the User-Agent string to detect the browser and operating system is not reliable and is a legacy practice. You won't be able to detect Windows 11 because Windows 11 will use "Window NT 10.0" which is the same that Windows 10 uses.

But you can use User-Agent client hints in new browsers like Edge 94+ and Chrome 95+.

For Windows 11, look for these request headers:

Sec-CH-UA-Platform set to 'Windows'
Sec-CH-UA-Platform-Version set to 13.0.0 and above

See this link for more information: Detecting Windows 11 using User-Agent Client Hints

like image 86
Albert Wiersch Avatar answered Oct 17 '22 02:10

Albert Wiersch