Question

Could you suggest an efficient way to identify a unique user with javascript (e.g. calculate an hash to send to the server side)?

EDIT: The point is that I can't 'intrude' into the browser (e.g. send cookies). And IPs are also not the option. And it has to be a client-side solution (therefore javascript).

Was it helpful?

Solution

A common solution to this problem is to calculate a unique ID on the server side, then push a cookie to the browser containing that ID (checking, first, to see whether that cookie has already been defined for the current browser).

Advertising networks use that technique fairly heavily to gather demographic information on web users.

EDIT By the way, the "unique ID" can simply be the first session ID associated with the user. Many frameworks can supply that for you.

OTHER TIPS

I upvoted Brian's answer but I'd like to add that the problem is identifying a unique user. Insisting that it be done in Javascript - which is stateless beyond the page level unless there is participation at the server level - just isn't a fruitful approach.

A "unique" string could be the user's IP address, but beware that different users behind a corporate firewall, for example, could appear with the same IP.

The IP address of user is already available at server level, you don't need js.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top