https://github.com/Colex/node-cookieless
Cookieless.js 是一个轻量级的使用 Etag 进行访客跟踪的 Node.js 扩展库。使用该库无需 Cookie 支持。
客户端代码:
123456789$.ajax({
url:
"http://127.0.0.1:7123/i.js"
,
jsonp:
"callback"
,
dataType:
"jsonp"
,
success:
function
( visitor ) {
//Do something
trackImpressionFor(visitor.id, visitor.session);
//example
}
});
服务器端代码:
123456789var
CookielessTracker = require(
'cookieless'
);
/*
Note: it's not mandatory to start a beacon, you may handle the requests
yourself and just use the tracker's API
*/
CookielessTracker.startBeacon(7123,
'0.0.0.0'
,
function
(visitor) {
redis.incr(
'visits.'
+visitor.id);
});