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

Posted on 2007-10-20
Last Modified: 2013-11-07
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"?

Question by:volking
    LVL 14

    Accepted 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???
    LVL 5

    Author Comment

    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?
    LVL 5

    Author Comment

    Oh wow! I just realized. This is how a website "REMEMBERS" me and automatically logs me into their site (or not) .... wow ... cool!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Training Course: Java/J2EE and SOA

    This course will cover both core and advanced Java concepts like Database connectivity, Threads, Exception Handling, Collections, JSP, Servlets, XMLHandling, and more. You'll also learn various Java frameworks like Hibernate and Spring.

    This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
    Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
    Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    759 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now