Skip to content

Instantly share code, notes, and snippets.

View alanjames1987's full-sized avatar

Alan James alanjames1987

View GitHub Profile

Keybase proof

I hereby claim:

  • I am alanjames1987 on github.
  • I am alanjames1987 (https://keybase.io/alanjames1987) on keybase.
  • I have a public key ASAfHZl0MgnmPK2vfmBInxNOcV7JSgmD7GzN6kSZmbc-qgo

To claim this, I am signing this object:

@alanjames1987
alanjames1987 / Express
Created February 16, 2015 19:54
Express-Session-/-jQuery-AJAX-Fake-Cookie
// modify the req cookies to include session ids sent as part of the body
// this is so Express Session reads from the cookies correctly
app.use(function(req, res, next) {
var sessionId = req.param('sessionId');
// if there was a session id passed add it to the cookies
if (sessionId) {
var header = req.headers.cookie;
@alanjames1987
alanjames1987 / session.js
Last active August 29, 2015 14:12
Express / Socket.IO Session Sync
var cookie = require('cookie');
var cookieParser = require('cookie-parser');
var _sessionStore;
var _sessionSecret;
function plugin(data) {
// store the Express session cookie name, session store, and session secret for use later
_sessionCookie = data.name || 'connect.sid';