node-evercookie

by truongsinh

truongsinh / node-evercookie

This is a conenct/express middleware for evercookie.

126 Stars 42 Forks Last release: Not found MIT License 23 Commits 0 Releases

Available items

No Items, yet!

The developer of this repository has not created any items for sale yet. Need a bug fixed? Help with integration? A different license? Create a request here:

Evercookie Middleware for Connect/Express JS

Licence npm version Build Status Maintainability Total alerts Test Coverage Dependencies Status DevDependencies Status PRs Welcome code style: prettier <!-- OpenCollective --> <!-- OpenCollective -->

Express is a sinatra inspired web development framework for node.js, insanely fast, flexible, and simple. Evercookie is a Javascript API that produces extremely persistent cookies in a browser. It is written in JavaScript and additionally uses a SWF (Flash) object for the Local Shared Objects and, originally, PHPs for the server-side generation of cached PNGs and ETags.

This middleware port original PHP script to Connect/Express JS

Support

  • Node: 6 - 11
  • Express: 4.x, 5.x
  • See detail at Build Status

Usage

Install

npm install --save evercookie

In your code

Evercookie backend middleware needs cookie, thus

cookieParser()
middleware must come before Evercookie backend middleware. In addition, express server must serve front end assets, such as index.html and evercookie.js as well. ```js var express = require('express'); var evercookie = require('evercookie'); const cookieParser = require('cookie-parser')

var app = express(); app.use(cookieParser()); app.use(evercookie.backend()); app.use(express.cookieParser()); app.use(express.static(__dirname + '/public')); // be careful, you may want to use path.join instead! ```

Settings

Customized settings can be used, but up to this moment, it makes no sense to change the dafault one, as all these values are hardcoded in (frontend)

evercookie.js
.
js
//...
app.use(evercookie.backend({
  pngCookieName: 'evercookie_png',
  etagCookieName: 'evercookie_etag',
  cacheCookieName: 'evercookie_cache',
  pngPath: '/evercookie_png.php',
  etagPath: '/evercookie_etag.php',
  cachePath: '/evercookie_cache.php'
}));
//...

Contributing

Acknowledgement

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.