5

The Spring Session documentations describes as one of its usage benefits as written below.

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.

Technically, how does one leverage that benefit, how is it implemented?

Newbie
  • 7,031
  • 9
  • 60
  • 85

1 Answers1

6

As of Spring Session RC1, Spring Session will keep track of all the Sessions in a single cookie. Using a pattern like this:

0 defaultsession alias sessionid alias2 sessionid2

Then you can select which session you are actively using by ensuring that you have the query parameter of "_s" with the value of the alias. For example, requesting the URL /index?_s=alias2 would use sessionid2. If _s is undefined, then the session alias of 0 is used. This means /index would result in using default session. You can find this documented on CookieHttpSessionStrategy

For a working example, see the users sample.

Rob Winch
  • 21,440
  • 2
  • 59
  • 76