8

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?

Stephen
  • 7,994
  • 9
  • 44
  • 73

1 Answers1

12

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.

tjholowaychuk
  • 3,026
  • 1
  • 21
  • 6
  • @tjoholowaychuck: to clarify, the root app will do the work of retrieving the session, and follow-on applications will just get a copy of that session as retrieved, and that's a unique event per transaction? – Elf Sternberg Jun 15 '12 at 15:30