在 PHP 中使用 js API 使用 evercookie 创建 cookie 的问题


Issues Creating cookie with evercookie using js api in php

我想用永远的cookie创建永久cookie,但是当我在本地主机(Php wamp服务器)上运行cookie程序时,它不会创建任何cookie,并显示以下错误

Not Found
The requested URL /php/evercookie_etag.php was not found on this server.
Not Found
The requested URL /php/evercookie_cache.php was not found on this server.

我已从此链接下载了它 http://github.com/samyk/evercookie

我想创建一个永久的cookie,以便我可以识别我运行网页的系统,下面是我的代码,请帮助解决我的问题,提前感谢....

<html>
<head>
<script type="text/javascript" src="js/swfobject-2.2.min.js"></script>
<script type="text/javascript" src="js/evercookie.js"></script>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script>
//var ec = new evercookie();  
var ec = new evercookie({
        baseurl: '/test', http://localhost/test
        asseturi: '/assets', http://localhost/test/assets
        phpuri: '/php' http://localhost/test/php
    });

ec.set("id", "12345");

ec.get("id", function(value) { alert("Cookie value is " + value) });

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] + " votes<br>");
}
ec.get("id", getCookie);
</script>
</head>
</html>

你确定你的baseurl var是'/test'吗?例如,对于 github 源代码,它将是:

var ec = new evercookie({
    baseurl: '/evercookie-master',
    asseturi: '/assets',
    phpuri: '/php'
});