Skip to content

In windows 11 user agent always is "Windows NT 10.0" #27

@Chiwa1024

Description

@Chiwa1024

In windows 11 user agent always is "Windows NT 10.0"

If you want to read the "Sec-CH-UA-Platform-Version" header

  1. The server needs set header("accept-ch: Sec-Ch-Ua-Platform, Sec-Ch-Ua-Platform-Version") ;
  2. Subsequent requests will have Sec-CH-UA-Platform and Sec-CH-UA-Platform-Version headers.
  3. Check header: Sec-CH-UA-Platform = "Windows" and Sec-CH-UA-Platform-Version >= 13

Related links
https://learn.microsoft.com/en-us/microsoft-edge/web-platform/how-to-detect-win11

This is an example:

<?php
header("accept-ch: Sec-Ch-Ua-Platform, Sec-Ch-Ua-Platform-Version");

function isWin11(){
    if(isset($_SERVER['HTTP_SEC_CH_UA_PLATFORM']) &&
            $_SERVER['HTTP_SEC_CH_UA_PLATFORM'] == '"Windows"' && 
            isset($_SERVER['HTTP_SEC_CH_UA_PLATFORM_VERSION'])){

        if(13 <= intval(explode(".", preg_replace('/^"|"$/i', "", $_SERVER['HTTP_SEC_CH_UA_PLATFORM_VERSION']))[0])){
            return true;
        }

    }
    return false;
}

echo isWin11();

Test environment:

Sccess
✅ Windows 11 ; Chrome/117
✅ Windows 11 ; Edge/117

Not support
❌ Windows 11 ; Firefox/113

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions