简体   繁体   English

如何在已安装的快递应用中共享会话

[英]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() ). 我有一个相当复杂的基于快速的Web应用程序,它被分成几个子应用程序,也是快速应用程序(使用app.use() )。 How can I seamlessly use the same session between all parts of the app? 如何在应用程序的所有部分之间无缝地使用相同的会话?

the middleware bundled with Connect are "self aware" in that they will not duplicate work they've already done. 与Connect捆绑在一起的中间件是“自我意识”的,因为它们不会复制他们已经完成的工作。 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. 因此,例如,如果您已经拥有req.session,并且“root”应用程序和已安装的应用程序都使用session()中间件,则根应用程序的会话将起作用,而另一个将被忽略。 So it should work as-is. 所以它应该按原样运作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM