Learn how to a build a cloud-first strategyRegister Now

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • Last Modified:

how-to cookie that ID's the COMPUTER? SURFER? ANONYMOUS?

I need a cookie which lets my site recognize a specific ANONYMOUS user has returned? Example: My site lets anyone post messages as ANONYMOUS. But ... I would like to recognize the difference between ANONYMOUS(user707) and ANONYMOUS(user881). And be able to recognize this difference "every-time" the ANONYMOUS user returns to my site.

YES, I know there are dozens of ways to defeat this identification, but for what I'm doing "close-enough" is "good-enough", I don't need "bullet-proof"

So, tell me about a cookie I can drop on a surfer's computer (the first time they visit) and re-query every time they return, to identify "them" as "them"?

  • 2
1 Solution
seems like you are almost there already.

just set a cookie, set it's expiration to some date in the future (how far is up to you) and that will actually cause the cookie to be persisted on the user machine (if they allow cookies anyway, if they don't...) then, you can just look for that cookie any time a user hits your site.

here is how to set the cookie to a GUID, and have it last three months.

if (null != Request.Cookies["userguid"] && Request.Cookies["userguid"].Value.Length > 0)
    Response.Cookies["userguid"].Value = System.Guid.NewGuid().ToString();
    Response.Cookies["userguid"].Expires = DateTime.Now.AddMonths(3);

this only writes out the cookie to the page if the user has been to the site before.

now, how to track this on the server will depend on what you have available to you.
store this guid in a database, or a text file, or???
volkingAuthor Commented:
If, 2 hours later, another person uses the same computer to come to my website, I will NOT know it's a different person, UNLESS the new user had to sign on to the computer using their OWN user name and password. Correct? Cookies are stored separated in C:/DocumentsAndSettings/UserXYZ/... right?
volkingAuthor Commented:
Oh wow! I just realized. This is how a website "REMEMBERS" me and automatically logs me into their site (or not) .... wow ... cool!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now