5

I have a peculiar problem. My application has different levels of authentication. One specific level of user (super user) needs to be able to use the application as another user (subordinate user) that has lower privileges.

We decided that when the super user selects to be a subordinate user then another tab in the browser will be opened and will load the subordinate user's privileges and their respective cookie. The problem we have is: how can we get the reference for the new cookie in this new tab?

Also the super user will be able to open multiple tabs and each tab need to reference its own cookie.

1 Answer 1

1

You could have each tab generate a cookie with a unique id in the name such as "mysiteCookie" + unique value. Keep the "mysiteCookie" base the same across all tabs.

That should be enough to keep each cookie separate. In order to read the correct one you could set up two javascript methods, one used for navigation that automatically appends it's unique id to the cookie base and adds it to the URL as a parameter, and another that fires on load to read that parameter and retrieve the cookie.

It's not exactly pretty but it would work.

Edit:

If you are using asp.net you might want to look into Server.Transfer() when navigating between pages. It allows you to get variables from the previous page. With that you can remove logged in user from cookies and just read it from prior page state.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.