Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share sessions in mounted express apps

I have a fairly complex express based web application that is split up into a few sub apps which are also express apps (using app.use()). How can I seamlessly use the same session between all parts of the app?

like image 821
Stephen Avatar asked Oct 04 '11 16:10

Stephen


1 Answers

the middleware bundled with Connect are "self aware" in that they will not duplicate work they've already done. So for example if you have req.session already, and both the "root" app, and a mounted app utilize the session() middleware, the root app's session will work, and the other will be ignored. So it should work as-is.

like image 107
tjholowaychuk Avatar answered Oct 08 '22 16:10

tjholowaychuk