Question

How can I create object like TempData in nodejs? I thought maybe I can set flag 'IsTempData' to session and at the end of an application I would clear sessions which have this flag selected. But there is a problem: I have many asynchronous functions where I use tempdata, so application may end before I use tempdata. I hope you understand what I mean by ending application:

connect()
.use(connect.bodyParser())
.use(connect.query())
.use(connect.favicon())
.use(connect.cookieParser())
.use(connect.session({ secret: 'your secret here' }))
.use(function (req, res) {
    somefunction();

    // end of application, here I will clear sessions which have tempdata flag selected
}).listen(1234);
Was it helpful?

Solution

I came across your post looking for the same behavior. Since I couldn't find anything, I decided to implement something of my own, which will hopefully help you as well: NodeJS TempData Provider

Keep in mind, this was put together rather quickly, so if you have any issues, I'd appreciate your feedback.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top