Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8933525
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T09:33:38+00:00 2026-06-15T09:33:38+00:00

I have a corresponding problem by using the given example. In the example, the

  • 0

I have a corresponding problem by using the given example.
In the example, the session is used in the WebSocket by reloading it first:

  socket.on('set value', function (val) {
    sess.reload(function () {
      sess.value = val;
      sess.touch().save();
    });
  });

Trying to use it in my own application, i get the following exception:

  sess.reload(function () {
       ^
TypeError: Object #<Object> has no method 'reload'

I think the problem is, that no one defines the variable sess as session:

io.listen(app).set('authorization', function (data, accept) {
  if (!data.headers.cookie) 
    return accept('No cookie transmitted.', false);

  data.cookie = parseCookie(data.headers.cookie);
  data.sessionID = data.cookie['express.sid'];

  store.load(data.sessionID, function (err, session) {
    if (err || !session) return accept('Error', false);

    data.session = session;
    return accept(null, true);
  });
})

Maybe some has a short fix for this?

Problem solved: I tried to use this example: https://github.com/DanielBaulig/sioe-demo/blob/master/app.js with Express 3.0 and Redis.

Therefore i created a Redis Store (connect-redis) instead of a MemoryStore:

app.use(express.session({cookie: {expires: new Date(Date.now() + 30*60*60*24*1000)}, secret: SESSION_SECRET, key: SESSION_KEY, store: new RedisStore({host:'localhost', port:'6379', client: dbRedis})}));

Since the parseCookie-Method in connect moved i used

parseCookie = require('cookie').parse

instead of

connect.utils.parseCookie

To access the session in the cookie i modified the example by using the following:

sio.set('authorization', function (data, accept) {
  if (!data.headers.cookie) 
    return accept('No cookie transmitted.', false);

  data.cookie = parseCookie(data.headers.cookie);
  log.info('Cookie: $s', JSON.stringify(data.cookie));
  data.sessionID = data.cookie['letter.sid'];
  log.info('SessionId: %s', data.sessionID);

  dbRedis.get(data.sessionID, function (err, session) {
    if (err || !session) return accept('Error ' + session, false);

    data.session = session;
    return accept(null, true);
  });
})

Now my Problem is, that i cant load the session from Redis because the Session IDs differ
Printing the Session ID on a page (req.sessionID) i get: n+57bnkLr+iXkMLbStWdFzK5
But in Redis the following ID is Stored:

[2012-12-03T22:14:56.632Z]  INFO: Postbox/78964 on capns-mba.local: Cookie: $s {"SQLiteManager_currentLangue":"4","connect.sid":"s:xvYdDm5C0MEIg53EG8JgqBnM.Tx8+PMKa570zk6qt9vmCjRz2p/LP/COyyqGSm+VKxww","letter.sid":"s:n+57bnkLr+iXkMLbStWdFzK5.XPHh1xXrK9D4cPfJ7HcHO11PKk8FXLg6fIRGaWb/+jI"}
[2012-12-03T22:14:56.632Z]  INFO: Postbox/78964 on capns-mba.local: SessionId: s:n+57bnkLr+iXkMLbStWdFzK5.XPHh1xXrK9D4cPfJ7HcHO11PKk8FXLg6fIRGaWb/+jI

Obviously the req.sessionID is part of the SessionID saved in the cookie/redis – but why? And which is the correct sessionID?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T09:33:40+00:00Added an answer on June 15, 2026 at 9:33 am

    Look at this piece of code from session middleware ( line 267 ):

    var val = 's:' + signature.sign(req.sessionID, secret);
    

    where signature.sign function is a concatenation ( pseudo-code ):

    req.sessionID + "." + hash(secret)
    

    where hash is a custom function ( see this for more details ).

    This means that it is just a signing convention for cookies ( to make it more secure ). You can retrieve your sid by calling:

    var signature = require( "cookie-signature" ),
        prefix = "s:";
    
    var real_sid = sid.replace( prefix, "" );
    real_sid = signature.unsign( real_sid, SESSION_SECRET );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a function that sends out site emails (using phpmailer), what I want
I have multiple UITextViews with corresponding .txt files. I'm reading them with NSString's stringWithContentsOfFile
I have several DTO and corresponding POCOs. What is the recommended way to convert
I have Messages and User models with corresponding tables. The Messages table has such
I have two servlets that access two corresponding Axis2 web services on the same
I have two sets of elements with (sometimes) corresponding rel and id attributes: <a
I have about twenty UITextViews and corresponding .txt files. What I want is to
I have a series of checkbox inputs and corresponding text area inputs to allow
I have a list of textboxes with corresponding labels. When the user inputs a
I have a table of increasing dates (with gaps) and corresponding values date |

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.