Pergunta

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.

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top