Giter Site home page Giter Site logo

node-evercookie's Introduction

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

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.

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.

//...
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

node-evercookie's People

Contributors

monkeywithacupcake avatar truongsinh avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

node-evercookie's Issues

Node != Express

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

cannot install

im getting this error

niemand@Anya ~ $ npm install --save evercookie
npm WARN saveError ENOENT: no such file or directory, open '/home/niemand/package.json'
/home/niemand
└─┬ [email protected]
└─┬ [email protected]
├── [email protected]
└── [email protected]

npm WARN enoent ENOENT: no such file or directory, open '/home/niemand/package.json'
npm WARN niemand No description
npm WARN niemand No repository field.
npm WARN niemand No README data
npm WARN niemand No license field.

PHP cache file response as text

<?php
/* evercookie, by samy kamkar, 09/20/2010
 *  http://samy.pl : [email protected]
 *
 * This is the server-side simple caching mechanism.
 *
 * -samy kamkar
 */

// we get cookie name from current file name so remember about it when rename of this file will be required 
include dirname(__FILE__) . DIRECTORY_SEPARATOR . '_cookie_name.php';
$cookie_name = evercookie_get_cookie_name(__FILE__);

// we don't have a cookie, user probably deleted it, force cache
if (empty($_COOKIE[$cookie_name])) {
    header('HTTP/1.1 304 Not Modified');
    exit;
}

header('Content-Type: text/html');
header('Last-Modified: Wed, 30 Jun 2010 21:36:48 GMT');
header('Expires: Tue, 31 Dec 2030 23:30:45 GMT');
header('Cache-Control: private, max-age=630720000');

echo $_COOKIE[$cookie_name];

I check this file response "link" and the response is always txt as above. No php script was parse. How can I solve this!?

Node support 6+?

Is there any support on Node 5/6? I see it was recently added to the README that only 0.* versions are supported.

How stable would it be on 6.3?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.