window.open()清除会话 [英] window.open() clears session

查看:620
本文介绍了window.open()清除会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的应用程序中有几个portlet.如果我使用window.open()方法打开一个URL,则会话ID更改并在其他portlet中引起错误.如果我不打开此网址,则一切正常.但是,一旦打开了这个新窗口,便会清除该会话,并且由于缺少某些值,因此其他Portlet会引发异常. 在浏览器的地址栏中,我输入了javascript:alert(document.cookie);查看JSESSIONID.它在整个页面中保持不变,并且在我单击在新窗口中启动新URL的链接时会更改.我用的是IE8.

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.

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

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

推荐答案

您要传递给window.open()的URL是什么?获取IE 8以在弹出窗口中维护JSESSIONID的一种简单方法是在portlet标记的window.open()调用中使用 relative URL.关键是域名必须保持完全相同.这是onclick事件中带有window.open()的按钮的示例:

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>

我正在使用Websphere Portal,所以'/wps/portal'只是链接到主页.

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?

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

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

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.

这篇关于window.open()清除会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆