Get Even More Visitors To Your Blog, Upgrade To A Business Listing >>

Can't store result in session from async waterfall

Can't store result in session from async waterfall

Problem

I have a series of methods I run using async.waterfall which then return a result. I Store that result into a request.session variable because I use Ajax and work with the result later on. However, I find that I can set the value of the session variable, but later on I cannot retrieve it.

Here's the code from the waterfall.

async.waterfall([
   //Some functions
], function(err, result) {
    request.session.cases = result;
    response.render('template.jade', {
        items : result
    });

I then perform a jquery load to another url which then filters cases in request.session.cases. But, I find that request.session.cases is undefined!

app.get('/case/:bugid', function(request, response) {
    console.log(request.session.cases); //undefined
}

The weird part is that I can set request.session.cases to anything other than result (I can even set it to result[0]) and it will be fine. I've also printed out the value of result before I do the Ajax call and it is indeed populated with an array of objects.

Problem courtesy of: n00b

Solution

cookieSession has a very small size of data that you can store into it. The data I was trying to store was too big for a cookieSession. Therefore I switched to using a session for that type of data, and using a normal cookie for user login.

Solution courtesy of: n00b

Discussion

View additional discussion.



This post first appeared on Node.js Recipes, please read the originial post: here

Share the post

Can't store result in session from async waterfall

×

Subscribe to Node.js Recipes

Get updates delivered right to your inbox!

Thank you for your subscription

×