Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get human readable device/browser combination from user agent string?

Tags:

user-agent

web

With LinkedIn you can see a list of sessions, and sign them out from a distance.

Within that list you can see a human readable way what kind of device / browser combination you used for that session.

LinkedIn example

The current state of UserAgent strings is quite a mess.

Question: Is there a reliable way (or library) to extract this information clean and reliable from the user agent string?

What I'm trying to prevent

One big hairy ball of spaghetti with 30 if ( str.contains("yadadaya") under each other that have to tested and that will most likely break or go out of date really fast.

Looking for something preferably in C# or JavaScript

like image 433
Dirk Boer Avatar asked Jul 13 '15 15:07

Dirk Boer


People also ask

What is the browser user agent string?

A browser's User-Agent string (UA) helps identify which browser is being used, what version, and on which operating system. When feature detection APIs are not available, use the UA to customize behavior or content to specific browser versions.

How do I find my user agent browser?

The user-agent string of the browser is accessed using the navigator. userAgent property and then stored in a variable. The presence of the strings of a browser in this user-agent string is detected one by one. Detecting the Chrome browser: The user-agent of the Chrome browser is “Chrome”.

What does a user agent string contain?

Described in the HTTP standard, the User-Agent string contains a number of tokens that refer to various aspects of the request, including the browser's name and version, rendering engine, device's model number, operating system and its version, etc.

Where is the user agent string?

The User-Agent (UA) string is contained in the HTTP headers and is intended to identify devices requesting online content. 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.


1 Answers

You probably want something like ua-parser-js or uap-csharp.

like image 152
bennettp123 Avatar answered Sep 27 '22 21:09

bennettp123