[英]How to implement Evercookie in sails.js/node.js?
I followed the link as 我跟随链接为
https://github.com/truongsinh/node-evercookie https://github.com/truongsinh/node-evercookie
First created a middleware for connect in config/http.js 首先在config / http.js中创建了一个用于连接的中间件
and then followed the link : 然后点击链接:
Results In chrome Console : chrome控制台中的结果:
Storage mechanism userData returned: undefined<br>
Storage mechanism cookieData returned: undefined<br>
Storage mechanism localData returned: 12345<br>
Storage mechanism globalData returned: undefined<br>
Storage mechanism sessionData returned: 12345<br>
Storage mechanism windowData returned: 12345<br>
Storage mechanism historyData returned: undefined<br>
Storage mechanism pngData returned: undefined<br>
Storage mechanism etagData returned: <br>
Storage mechanism cacheData returned: <br>
Storage mechanism dbData returned: 12345<br>
Storage mechanism lsoData returned: undefined<br>
Storage mechanism slData returned: undefined<br>
At front end Java script it is giving the correct id in alert as I set. 在我设置的前端Java脚本中,它会在警报中提供正确的ID。
At Server Side : I get the cookieValue= undefined 在服务器端:我得到cookieValue = undefined
Kindle help me whether this is the right way or I am missing anything in between. Kindle可以帮助我,无论这是正确的方法还是我之间缺少任何东西。
I tried a lot then used evercookie.js file from the website " http://samy.pl/evercookie/ " itself. 我尝试了很多,然后从网站“ http://samy.pl/evercookie/ ”本身使用了evercookie.js文件。
then make changes in http middleware given as follows : 然后在http中间件中进行如下更改:
var evercookie = require('evercookie');
var cookieParser = require('cookie-parser');
app.use(cookieParser());
app.use(evercookie.backend());
app.use(cookieParser());
app.use(require('connect').static(__dirname +'../public')); // be careful, you may want to use path.join instead!
app.use(evercookie.backend({
pngCookieName: 'evercookie_png',
etagCookieName: 'evercookie_etag',
cacheCookieName: 'evercookie_cache',
pngPath: '/path/evercookie_png.php',
etagPath: '/path/evercookie_etag.php',
cachePath: '/path/evercookie_cache.php'
}));
Note: 'path' is a location from where ec.set and ec.get method is called. 注意:“路径”是调用ec.set和ec.get方法的位置。 Now I am able to get cookie data for etagData, cacheData and cacheData. 现在,我可以获取etagData,cacheData和cacheData的Cookie数据。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.