Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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