skip to Main Content

In PHP is there any way to store user’s browser details?? The reason for this is that I want to analyse all the unique devices the user is using his/her login credentials from. By browser details I mean if there is any sort of unique code a browser has that I can store to identify whether the logged in device is new or an existing one. I’ve already used get_browser(), it’s returning the browser versions and I don’t understand how to use it. Any help?

2

Answers


  1. OPTION 1

    This returns an string

    $_SERVER['HTTP_USER_AGENT']
    

    OPTION 2

    This will return an array of details.
    You can try this function, then you can store this details to your database.
    if this doesnt work. try reading this get_browser not working

    $browser = get_browser(null, true);
    

    The above example will output something similar to:

    Array
    (
        [browser_name_regex] => ^mozilla/5.0 (windows; .; windows nt 5.1; .*rv:.*) gecko/.* firefox/0.9.*$
        [browser_name_pattern] => Mozilla/5.0 (Windows; ?; Windows NT 5.1; *rv:*) Gecko/* Firefox/0.9*
        [parent] => Firefox 0.9
        [platform] => WinXP
        [browser] => Firefox
        [version] => 0.9
        [majorver] => 0
        [minorver] => 9
        [cssversion] => 2
        [frames] => 1
        [iframes] => 1
        [tables] => 1
        [cookies] => 1
        [backgroundsounds] =>
        [vbscript] =>
        [javascript] => 1
        [javaapplets] => 1
        [activexcontrols] =>
        [cdf] =>
        [aol] =>
        [beta] => 1
        [win16] =>
        [crawler] =>
        [stripper] =>
        [wap] =>
        [netclr] =>
    )
    

    you can check docs here: https://www.php.net/manual/en/function.get-browser.php

    Login or Signup to reply.
  2. Here is it.

    <?php
    echo $_SERVER['HTTP_USER_AGENT'] . "nn";
    
    $browser = get_browser(null, true);
    print_r($browser);
    ?>
    

    Reference: https://www.php.net/manual/en/function.get-browser.php

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search