I would like to capture the "computer name"/"device name" of the user. (Ex: Joes-iPhone) It seems like a nice touch to be able to see what devices have connected with the users login so they can see if there is unauthorized access to their account. Over and over I see people say this is impossible from a web page for JavaScript, HTML, PHP, etc. Yet when I log into my bank, Facebook, Google. Low and behold, there is every device I've connected with. This means it is most definitely possible. There was one instance where one of my accounts was logged into by someone and this was a big help in identifying what was going on and I love this feature now. I would like to implement this but am stuck in a city full of dead end roads! Does anyone have any knowledge of how they are accessing this? Or even theories? I don't care what language or technique. I'm very curious to see what people come up with. I do have an app for Facebook, so I could see the app accessing it and storing it for the browser site, but I have no app for the bank or Google and I have devices listed in Facebook that were not used within an app, only through the browser. To my knowledge I have never authorized any access to anything beyond what the browser is capable of, so there must be something I'm missing.
-
its called cookies and the user agent. thats all those other services use. – Daniel A. White Jun 05 '15 at 00:39
-
Your bank might be telling you your browser type and location but I doubt it has specific, personal device information. – Lance Jun 05 '15 at 00:40
-
No, it most definitely shows me device name. For mobile devices as well as my Mac and laptop. I'm aware of user agent info, but they have captured more than that.. Just log into your Google account and check your history. – Chris Jun 05 '15 at 01:13
2 Answers
Short answer: It's true, it can't be done.
But why not??
Your device name is used when your device connects to your router -- but that's where it stops. Your router doesn't allow that information to be broadcast any further. When your computer/tablet/phone requests a web page, your router is the one actually asking for the page -- and he refers to himself by his public IP, which is shared by all the devices on your LAN.
Second-Best
What can be seen by external Internet entities is your user-agent (the type of browser you're using), which can give someone a pretty good idea of what operating system you're using, and therefore what sort of device you're on (mobile vs. desktop/laptop, Windows vs. Mac, etc.). The user-agent info is available as a string, and can be accessed by PHP via the $_SERVER['HTTP_USER_AGENT']
variable.

- 2,380
- 4
- 16
- 27
-
I'm aware of USER_AGENT.. But they have the actual device name for all my mobile devices as well as my laptop and Mac.. – Chris Jun 05 '15 at 01:15
-
I have (as 95% of the first world population) a Google account as well, and I've never seen it display my device name. I'd be curious to see where it is you've come across this exactly? – kittykittybangbang Jun 05 '15 at 01:22
-
Mobile:Go to google.com and log in. Click your photo in the top right and you will see the accounts you have. Scroll all the way down to the fine print links at the bottom and click "Account Settings". Go to "device info & notifications", scroll to "device history". I have a screen cap but I don't know if you can put photos here.. – Chris Jun 05 '15 at 02:01
-
I see where my devices are listed, but no device names. What is shown there is 'Linux' (my laptop) and 'Samsung Galaxy S4 Mini' (my cell phone). That information would have been gathered from `$_SERVER['HTTP_USER_AGENT']`. My device names are not, however, listed here. – kittykittybangbang Jun 06 '15 at 03:21
-
-
@Chris, but it's a Google account and you're probably accessing it with Google software (e.g. an Android device, or Chrome), so the installation may be able to read this information off your computer and provide it to Google. – Lee Kowalkowski Aug 20 '21 at 12:56
The PC name is only accessible through LAN (another PC connected to the same modem/router), if such a request hasn't been blocked on your PC. It is not distributed by browsers.
What browsers transmit is the browser info and operating system as well as the IP address. That's all. Some sites allow you to give a nickname to each machine so you can identify them, and they can then use cookies to remember which is which.
EDIT: The only thing I can see is that they could be using Java or Flash to do it.

- 6,314
- 1
- 32
- 58
-
I've never provided a nickname for any of them and they are exact matches to my device names – Chris Jun 05 '15 at 01:16
-
Then perhaps they do so with Java or Flash. They're definitely using something else than browser code. I found this about it: http://stackoverflow.com/questions/7883542/getting-the-computer-name-in-java – Domino Jun 05 '15 at 01:19