如何让两个浏览器窗口共享相同的“会话”?

时间:2021-07-24 21:00:33

I have an app that needs to open a new window (in the same domain) so the user can view a report, but on some browsers* the new window doesn't share the non-persistent cookie of the original window, which causes the user to have to sign in again. Is there anything I can do to stop the user having to sign in again in the new window?

我有一个应用程序需要打开一个新窗口(在同一个域中),以便用户可以查看报告,但在某些浏览器*新窗口不共享原始窗口的非持久性cookie,这会导致用户必须再次登录。有什么办法可以阻止用户在新窗口中再次登录吗?

*In fact, in IE7 it is sporadic - sometimes new windows share cookies, sometimes not.

*事实上,在IE7中它是零星的 - 有时新窗口共享cookie,有时不共享。

5 个解决方案

#1


1  

IE7 does seem to generate new processes with a different algorithm than IE6, and can cause issues with session cookies.

IE7似乎确实使用与IE6不同的算法生成新进程,并且可能导致会话cookie出现问题。

The most reliable solution is probably going to be to architect around it - either with cookieless sessions, a persistent cookie, or just serializing the data you need in the page.

最可靠的解决方案可能是围绕它构建 - 使用无cookie会话,持久性cookie或只是序列化页面中所需的数据。

#2


3  

I thought IE7 shared non-persistent cookies with tabs in the same window, as well as windows that were generated from the current window (whether or not this is the same for manual opens like File->New, or programmatic script opens, I'm not sure), but that fresh instances did not.

我认为IE7在同一个窗口*享了带有选项卡的非持久性cookie,以及从当前窗口生成的窗口(无论是否为手动打开都是相同的,如File-> New,或者程序脚本打开,我'我不确定),但新的情况没有。

Firefox shares them across all windows, regardless of how they were opened. I've always assumed that this is just the way it is, and you'd have to use persistent cookies, cookie-less sessions, or develop a single sign-on/ticketing mechanism to work around it.

Firefox在所有窗口*享它们,无论它们是如何打开的。我一直认为这就是它的方式,你必须使用持久性cookie,无cookie会话或开发单点登录/票务机制来解决它。

#3


1  

I'm using ASP.NET and relying on the behaviour of sessions being shared across browser windows and it's working for me. In fact, I'm even using it for the same reason as you to show a report in the new window :)

我正在使用ASP.NET并依赖于跨浏览器窗口共享会话的行为,它对我有用。事实上,我甚至使用它的原因与您在新窗口中显示报告的原因相同:)

#4


0  

They should share cookies. That has been my experience in the past. I'll edit once I've had a play.

他们应该共享cookie。这是我过去的经历。我玩过一次后我会编辑。

#5


0  

Could it be related to how you are opening the window, e.g. - JavaScript vs. target tag?

它可能与你打开窗户的方式有关,例如 - JavaScript与目标标签?

#1


1  

IE7 does seem to generate new processes with a different algorithm than IE6, and can cause issues with session cookies.

IE7似乎确实使用与IE6不同的算法生成新进程,并且可能导致会话cookie出现问题。

The most reliable solution is probably going to be to architect around it - either with cookieless sessions, a persistent cookie, or just serializing the data you need in the page.

最可靠的解决方案可能是围绕它构建 - 使用无cookie会话,持久性cookie或只是序列化页面中所需的数据。

#2


3  

I thought IE7 shared non-persistent cookies with tabs in the same window, as well as windows that were generated from the current window (whether or not this is the same for manual opens like File->New, or programmatic script opens, I'm not sure), but that fresh instances did not.

我认为IE7在同一个窗口*享了带有选项卡的非持久性cookie,以及从当前窗口生成的窗口(无论是否为手动打开都是相同的,如File-> New,或者程序脚本打开,我'我不确定),但新的情况没有。

Firefox shares them across all windows, regardless of how they were opened. I've always assumed that this is just the way it is, and you'd have to use persistent cookies, cookie-less sessions, or develop a single sign-on/ticketing mechanism to work around it.

Firefox在所有窗口*享它们,无论它们是如何打开的。我一直认为这就是它的方式,你必须使用持久性cookie,无cookie会话或开发单点登录/票务机制来解决它。

#3


1  

I'm using ASP.NET and relying on the behaviour of sessions being shared across browser windows and it's working for me. In fact, I'm even using it for the same reason as you to show a report in the new window :)

我正在使用ASP.NET并依赖于跨浏览器窗口共享会话的行为,它对我有用。事实上,我甚至使用它的原因与您在新窗口中显示报告的原因相同:)

#4


0  

They should share cookies. That has been my experience in the past. I'll edit once I've had a play.

他们应该共享cookie。这是我过去的经历。我玩过一次后我会编辑。

#5


0  

Could it be related to how you are opening the window, e.g. - JavaScript vs. target tag?

它可能与你打开窗户的方式有关,例如 - JavaScript与目标标签?