In my web application I need to open another (browser) window with a new
session in such a way that it does not close the sesstion in the opening
window.
The scenario is as follows: Administrator changes some user profiles and
need to check the changes. I provided a link to open the new window, but as
soon as I login as another user in the new window - the old window loses
administrative profile.
If you need to do this for testing, the trick is to use a different browser. For example, if you are working in Internet Explorer, open up Firefox.
As for doing this outside lab situations, it is very, very difficult as the session is tagged with a cookie which will be shared by all concurrent instances of your web browser.
This is a case where you will need to either do some serious rejiggering of the system or the requirement.
The issue is that sessions are made to work by creating a temporary session ID cookie. This cookie remains in memory so long as any instance of that browser session is open. You cannot just temporarily make a new session. The administrator will have to destroy the session and login as the user.
Could this be the answer? I have .Net 1.1 and in my simple test it appears to work when a second window of the browser (IE) was opened by using File/New or Ctrl/N.
I found this on Google:
Request.Cookies(“ASP.NET_SessionId”).Expires = Now
Weirdest thing I’ve ever heard: That the world was created by an invisible guy who loves me but will torture me for all eternity if I do not believe in him.
Well, I tried File/New and Ctrl-N a second and third time to open a 3rd and 4th instance and it repeats the 2nd instance.
Anyone else have any other clues?
Weirdest thing I’ve ever heard: That the world was created by an invisible guy who loves me but will torture me for all eternity if I do not believe in him.
Could it work every time if the string “ASP.NET_SessionId” was replaced with something that was generated randomly?
Weirdest thing I’ve ever heard: That the world was created by an invisible guy who loves me but will torture me for all eternity if I do not believe in him.
You say your administrator privilages are lost when you login as the user to test the settings, could this not be because your login uses the same session for users? Could it not be possible to set an Admin session and a User session?
Thats the simple way if you were to use a modal window, but if your just using a new window (javascript window.open) then you’d have to maintain the session on both pages, but one for a different user.
Or you could create a clone session, meaning Session[“Clone”], which if null your script will read from the normal user session otherwise it would read from this.
The company I work for, we have an online management system for Data Storage (the business I work in) which sometimes can become very funny with certain users, so we created a clone user section that allowed us to select the user and login as if we were them, this was simply done by creating a clone session.
We then setup our scripts to look for this clone session, if it was present take the values from that user, otherwise use the user session (as if the user is really logged in)
Just another note, what you can do, is if the user is an admin when they login, set both the admin session and user session to the same data.
When you want to clone a user, on the pages that will be tested, if the two session are not the same (ie you have now populated the user session with the user you want to clone) then automatically read from the user session, whereas in your control panel use the other way round, use the admin session to authenticate the actions you are running.
To be honest, my brains fried and i’m at work, so I can’t really do much of an example without creating everything that goes with it.
If you use cookieless sessions you should be able to use multiple sessions against the same application, as the session identifier sits in the url. A link to a page without the session identifier should create a new session.
Another option is to create to applications (in seperate virtual dirs of IIS), but mapping to the same directory. This should fool IIS into believing that it’s two seperate application, but sharing codebase, configurations and data.
Could the following be a valid solution to allowing 2 different Users to be logged on and connected to the application, from the same PC when you open a second window in IE using File/New or Ctrl-N, without interfering with each others’ data?