Spring Session 文档描述了它的使用好处之一,如下所述。
Allowing for a single browser to have multiple simultaneous sessions in a transparent fashion. For example, many developers wish to allow a user to authenticate with multiple accounts and switch between them similar to how you can in gmail.
从技术上讲,人们如何利用这种好处,它是如何实现的?
最佳答案
从 Spring Session RC1 开始,Spring Session 将跟踪单个 cookie 中的所有 session 。使用这样的模式:
0 defaultsession alias sessionid alias2 sessionid2
然后,您可以通过确保您拥有带有别名值的“_s”查询参数来选择您正在使用的 session 。例如,请求 URL/index?_s=alias2 将使用 sessionid2。如果 _s 未定义,则使用 session 别名 0。这意味着/index 将导致使用默认 session 。您可以在 CookieHttpSessionStrategy 上找到此文档。
有关工作示例,请参阅 users sample .
关于spring - Spring Session 如何在单个浏览器中支持多个 session ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25560825/