user1498040
user1498040

Reputation: 1

Sharing session object accross multiple browsers

Is it possible to share session objects like user object accross multiple browser? My requirement is if user tries to switch between different browsers(IE, Chrome or Fireforx), the application should allow the navigation along with sharing of user object.

Upvotes: 0

Views: 655

Answers (2)

user1429080
user1429080

Reputation: 9166

It IS possible. But it would require you to write your own SessionIDManager class:

http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionidmanager.aspx

If you create your own SessionIDManager YOU decide how you will determine if a request belongs to a specific session or not. The client IP should at least be one parameter, some application specific key could be another etc. The actual session key that is returned could be a suitable string representation of a hash of all the parameters (the generated session id MUST be unique for each session).

Once you have you SessionIdManager done you can hook it up in web.config:

<sessionState mode="[mode]" ...
    sessionIDManagerType="[full type name of your class here]" ... />

So it can be done.

But I would personnally not make such a class unless there is some really compelling reason to do it:

  • It would be really easy to get it wrong and mix up sessions for different users.
  • What if different user access you site through the same proxy? What
    if there is a load balancer in front of you site (=all requests seem to come from the same IP). And so on.

And also, maybe most importantly:

  • It breaks the users' expectation of how sessions usually works...

Upvotes: 0

Adil
Adil

Reputation: 148110

Sharing session between browsers is not possible, Session cookie is used by browser to identify each client uniquely and it is stored in browser memory. So one browser is not allowed to access the memory of other browser and this makes it impossible to share session between different browsers. Reading more about session cookies could make it more clear.

Upvotes: 1

Related Questions