开发者

Loading the same session in 2 iframes on the same domain

I have a requirement to have multiple iframes on one page, that all interact with each other. The way our application is laid out requires that those iframes are running in the same session, in order to share data about what's selected and etc. with the other ones.

The problem is on first page load, both iframes load a URL, which obviously won't have the session cookie in the request. So both iframes create a new session and put their data into it. However, they both then send their session cookie down, and the last request overwrites the previous ones. From there, both 开发者_开发技巧iframes use the same session, but only the last loaded iframe has valid session data in it.

If I refresh the "container" page, everything works fine (because the session cookie is valid).

Unfortunately due to limitations in the "container" application, we cannot specify an explicit order of loading there. Already thought of that solution...


So I got this worked out (I really should have posted this like a year ago)...

Basically when the user loads the page, I ensure that the session cookie is the same as the currently executing request. So on the #1 request by a particular user, I just proceed as normal, except I make a note that this user has a request going.

Any requests that come in while #1 is still going with get held up in OnBeginRequest, until #1 has had the session initialized. When #1 gets its session initialized, he updates a shared instance with the session information, and then releases all the other threads.

Works well.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜