window.open() 清除会话

发布于 2024-08-07 23:47:16 字数 294 浏览 6 评论 0原文

我的应用程序中有几个 portlet。如果我使用 window.open() 方法打开 URL,则会话 ID 会发生更改并导致其他 Portlet 中出现错误。如果我不打开这个网址,一切都会正常。但是,一旦打开这个新窗口,会话就会被清除,并且其余的 portlet 会抛出异常,因为某些值丢失了。 在浏览器的地址栏中输入 javascript:alert(document.cookie);查看 JSESSIONID。它在整个页面中保持不变,当我单击在新窗口中启动新网址的链接时,它会发生变化。我用的是IE8。

任何在 IE 中维护会话状态的建议将不胜感激。

I have several portlets in my application. If I open a url using window.open() method, the session id changes and causes an error in other portlets. If I don't open this url, everything works fine. But once this new window is opened, the session is cleared and the rest of the portlets throws an exception since some values are missing.
In the address bar of the browser I typed in javascript:alert(document.cookie); to see the JSESSIONID. It remains constant throughout the page and changes when I click the link that launches a new url in new window. I used IE8.

Any suggestions to maintain the session state in IE would be greatly appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

思慕 2024-08-14 23:47:16

您传递给 window.open() 的 URL 是什么?让 IE 8 在弹出窗口中维护 JSESSIONID 的一个简单方法是在 portlet 标记中调用 window.open() 时使用相对 URL。关键是域名保持完全相同。下面是 onclick 事件中带有 window.open() 的按钮示例:

<button onclick="javascript:window.open('/wps/portal')">Home Page</button>

我使用的是 Websphere Portal,因此“/wps/portal”仅链接到主页。

另外,您打算将弹出窗口的目标设置为什么?具有相同会话的不同门户页面?

更新:鉴于 window.open() 的目标是托管在同一域上的独立 Web 应用程序...

门户服务器和托管 Web 应用程序的应用程序服务器具有独立的会话,但它们默认情况下,两者都使用名为 JSESSIONID 的 cookie。第一次访问 Web 应用程序时,应用程序服务器会覆盖门户的 cookie,导致对门户的每个后续请求都具有错误的会话 ID。当这种情况发生在我身上时,我的解决方案是将门户配置为将其会话 cookie 命名为其他名称(例如 PORTALSESSIONID),这样两者就不会发生冲突。

What URL are you passing to window.open()? An easy way to get IE 8 to maintain the JSESSIONID in the popup would be to use a relative URL in the call to window.open() in the portlet markup. The critical thing is that the domain name remain exactly the same. Here's an example of a button with window.open() in the onclick event:

<button onclick="javascript:window.open('/wps/portal')">Home Page</button>

I'm using Websphere Portal, so '/wps/portal' just links to the home page.

Also, what do you intend to be the target of the popup window? A different portal page with the same session?

Update: Given that the target of the window.open() is an independent web application hosted on the same domain...

The portal server and the application server hosting the web application have independent sessions, but they both use a cookie called JSESSIONID by default. The first time you access the web application, the application server overwrites the portal's cookie, causing every subsequent request to the portal to have the wrong session id. When this happened to me, my solution was to configure the portal to name its session cookie something else (e.g. PORTALSESSIONID) so the two do not conflict.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文