0

I tried using the IP address of the users's computer but I realized that the public Ip address of all computer is same in a particular network. But I want to display different images to different users in my college network.There is no login info of user, so what can I use to uniquely identify a user or a user's computer in javascript.

Thanks

Sanjana S
  • 11
  • 2
  • 1
    Use a cookie. That's what it's for. – Brad Oct 14 '14 at 01:33
  • If you don't have user login information then you don't actually have information for differentiating users. cookie could be a solution, but it is in-browser and user could clear it or user another browser. – Shuping Oct 14 '14 at 01:37
  • you can't id users without a login, only devices. how would you know to show my PC the same image as my phone? – dandavis Oct 14 '14 at 02:07

3 Answers3

0

You can try a session or a cookie but if you're doing it client side in Javascript there is no guarantee it will not change, or they won't use another browser.

If Flash is available, Flash cookies can be a possible cross-browser method. See How do I uniquely identify computers visiting my web site?

Community
  • 1
  • 1
Alexander Mistakidis
  • 3,130
  • 2
  • 20
  • 23
  • The Flash solution doesn't add anything useful, nor does it solve the problem of a user clearing their cookies. – Brad Oct 14 '14 at 01:34
  • Well it's shared across browsers, so more likely to uniquely identify a machine. But cookies in general are the answer and have their limitations, yes. – Alexander Mistakidis Oct 14 '14 at 01:38
0

Setting a cookie has already been mentioned, so i offer another possibility.

You could try some sort of hashing-function using the user's resolution/browser/settings/etc as input. It is not a surefire way but minor changes in the input will result in different hashes.

pbeedgen
  • 47
  • 1
  • 2
0

There are a couple of options: use a cookie (reasonably modern browsers have other methods such as Web Storage, but they amount to the same thing), or fingerprint the browser (e.g. with something like fingerprintjs). Each has pros and cons:

Cookie

All you need to do is generate is psuedorandom number on the first visit and store it in a cookie. A cookie can remain unchanged for a long time, until the user manually deletes the cookie, recreates their browser profile, etc. at which point the image will likely change, but a user could reasonably expect to see some changes when they perform one of these actions. Some users may block your cookie altogether - that just means they'll all get the same image. There are some laws governing the use of cookies, particularly in Europe, so if you're not already using one and your site is popular in Europe, you may need to add a disclaimer.

Fingerprint

A fingerprint is created by querying things like the screen resolution, installed plugins, software versions etc. then hashing the result to produce a short number/string that identifies the system - you just need to convert that identifier into a number between 1 and 7. The value will change when any of those parameters changes, however it's not affected by cleaning cookies, nor by the same laws that require disclosure of cookie use in some regions (there may be other laws governing the use of browser fingerprinting).

Edward Coffey
  • 447
  • 3
  • 8
  • many of those fingerprint sources could change on a user from an auto-update. canvas font fingerprinting is the newest/best method ATM. https://www.browserleaks.com/canvas – dandavis Oct 14 '14 at 02:04