samy's home page || follow my twitter || blog || email me || samy kamkar

evercookie -- never forget.

10/10/2010: Reported on by the New York Times

EXAMPLE


    Cookie found: uid = currently not set

    Click to create an evercookie. Don't worry, the cookie is a
    random number between 1 and 1000, not enough for me to track
    you, just enough to test evercookies.
    

    
Now, try deleting this "uid" cookie anywhere possible, then or

DOWNLOAD

    evercookie is written in JavaScript and additionally
    uses a SWF (Flash) object for the Local Shared Objects and
    PHPs for the server-side generation of cached PNGs and ETags.

    v0.4 BETA, released 10/13/2010
            download source here

    Or get it from github: http://github.com/samyk/evercookie

USAGE

    <script type="text/javascript" src="jquery-1.4.2.min.js"></script>
    <script type="text/javascript" src="swfobject-2.2.min.js"></script>
    <script type="text/javascript" src="evercookie.js"></script>

    <script>
    var ec = new evercookie({
    	baseurl: '/test', http://localhost/test
    	asseturi: '/assets', http://localhost/test/assets
    	phpuri: '/php' http://localhost/test/php
    });

    // set a cookie "id" to "12345"
    // usage: ec.set(key, value)
    ec.set("id", "12345");

    // retrieve a cookie called "id" (simply)
    ec.get("id", function(value) { alert("Cookie value is " + value) });

    // or use a more advanced callback function for getting our cookie
    // the cookie value is the first param
    // an object containing the different storage methods
    // and returned cookie values is the second parameter
    function getCookie(best_candidate, all_candidates)
    {
        alert("The retrieved cookie is: " + best_candidate + "\n" +
        	"You can see what each storage mechanism returned " +
    		"by looping through the all_candidates object.");

    	for (var item in all_candidates)
    		document.write("Storage mechanism " + item +
    			" returned: " + all_candidates[item] + "<br>");
    }
    ec.get("id", getCookie);

    // we look for "candidates" based off the number of "cookies" that
    // come back matching since it's possible for mismatching cookies.
    // the best candidate is most likely the correct one
    </script>

SEE ALSO

    csshack, best website ever