Skip to content

Instantly share code, notes, and snippets.

Revisions

  1. davej revised this gist Jan 17, 2011. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion connect-session-in-socket-io.js
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,7 @@
    // helper function that goes inside your socket connection
    client.connectSession = function(fn) {
    var cookie = client.request.headers.cookie;
    var sid = cookie.match(/connect\.sid=([^;]+)/)[1];
    var sid = unescape(cookie.match(/connect\.sid=([^;]+)/)[1]);
    redis.get(sid, function(err, data) {
    fn(err, JSON.parse(data));
    });
  2. nrub revised this gist Oct 7, 2010. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions connect-session-in-socket-io.js
    Original file line number Diff line number Diff line change
    @@ -1,8 +1,7 @@
    // helper function that goes inside your socket connection
    client.connectSession = function(fn) {
    var cookie = client.request.headers.cookie;
    var sid = cookie.match(/connect\.sid=([^;]+)/)[1]
    var session = {};
    var sid = cookie.match(/connect\.sid=([^;]+)/)[1];
    redis.get(sid, function(err, data) {
    fn(err, JSON.parse(data));
    });
  3. nrub created this gist Oct 6, 2010.
    14 changes: 14 additions & 0 deletions connect-session-in-socket-io.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,14 @@
    // helper function that goes inside your socket connection
    client.connectSession = function(fn) {
    var cookie = client.request.headers.cookie;
    var sid = cookie.match(/connect\.sid=([^;]+)/)[1]
    var session = {};
    redis.get(sid, function(err, data) {
    fn(err, JSON.parse(data));
    });
    };

    // usage
    client.connectSession(function(err, data) {
    console.log(data);
    });