Diane2
Diane2

Reputation: 160

Sessions - Two browser windows to use separate sessions

My website consists of a main dashboard page with a list of buildings.

By clicking on one building it opens a new browser window with many functions and features on that specific building.

With that being the case, I can have multiple browser windows open at one shot each representing another building's data. How can I set up that session data doesn't get mixed up between windows?

Upvotes: 0

Views: 944

Answers (2)

Icarus
Icarus

Reputation: 63956

You can identify each building's information by appending the building's unique identifier as part of the key when you store the data in session.

So instead of doing:

Session["Building"] = something;

do

Session["Building_"+buildingID] = something;

Now, using the building id, you can always find the appropriate info belonging to the building in the current window.

With that said, I would question why do you actually need to store this in Session? Isn't it cheap to get the data from the database every time? I wouldn't worry about performance unless you have really expensive operations on the database side.

Upvotes: 1

Fio
Fio

Reputation: 40

We're using a combination of storing an ID in ViewState on a given page to test against the ID of a complex Session object which handles different windows' data. Given the differences in tab, page and session handling by the different browsers, you can get some really quirky behavior.

Upvotes: 0

Related Questions