2

I'm trying to develop a feature for my own website that detects the specific devices that are accessing to my page and from which browser are entering my registered users. Something similar to what the telecommunications companies do i.e. Orange in Europe or Netflix. For instance: enter image description here

For identifying the devices I tried to get the MAC of the user who is accessing to relate that MAC address to my user. But the only solutions that I found only work in Internet Explorer and allowing some features of that browser. For instance : https://programming.vip/docs/three-methods-for-js-to-obtain-client-ip-address-mac-and-host-name.html

In the second place, getting the browser seems easier with property user-agent (Javascript and PHP) and only in Javascript with Navigator feature. But I don't know if it's the best solution out there.

Thanks in advance.

adrian
  • 37
  • 1
  • 5
  • 2
    From a web application you cannot identify the client's MAC address (reference: https://stackoverflow.com/questions/1420381/how-can-i-get-the-mac-and-the-ip-address-of-a-connected-client-in-php). Only a native app running on the device could do that. User-agent is possible to try and identify the browser (and there may be operating system data embedded in it too) but it is easy to spoof, so you cannot rely on it solely. – ADyson Mar 04 '22 at 12:31
  • 1
    What problem specifically are you trying to solve by detecting the device / browser? Or what feature are you trying to implement? Perhaps if you explain the context and requirements a bit more we can suggest a feasible approach to achieving it. – ADyson Mar 04 '22 at 12:32
  • The feature that I'm trying to implement is for device and browsing controlling. For instance, if you are a registered user of my website you can only access to my website from two different devices maximum, i.e. a mobile phone and a computer and from Chrome and Firefox. And then when I identify the browsers and devices register in my database along with the user. – adrian Mar 04 '22 at 12:51
  • 2
    Why not store the count of the sessions or logins in general? The device itself in this context is not interesting at all. – Teemu Mar 04 '22 at 13:05
  • 2
    I assume you mean concurrently? Well why don't you just keep a record of how many current logged-in sessions there are for each user? Then you don't need to worry about devices. (And of course if the user chooses to be logged in twice on the same device, e.g. in two different browsers, well that's their problem and you can always have some advice in your site's help pages suggesting to check if that if they run into the session limit.) – ADyson Mar 04 '22 at 13:05
  • 2
    Additional to UserAgent header being unreliable, there's [this](https://developer.chrome.com/docs/privacy-sandbox/user-agent/)., which makes the information even less useful. – Teemu Mar 04 '22 at 13:16
  • The feature is something similar to the image I just attached in the edited post. So if with the user agent is not enough. What more can I add or research about? – adrian Mar 07 '22 at 11:16
  • 1
    Well you can see from the screenshot that the IP is being logged. That can help, but you can also see that the IP is the same in each case (presumably because all the devices are on the same local network, and therefore (due to NAT) share the same public IP). But we've already told you a solution - just count the number of logged-in sessions for that user account. That's all Netflix is doing. It's logging the UA and IP to guess the device, for information and statistics, but it's not using that to actually control the number of streaming sessions. I see no evidence that it logs the MAC address – ADyson Mar 07 '22 at 11:24
  • Perfect ! I will take that path. Thanks for everything ! – adrian Mar 07 '22 at 15:05

0 Answers0