开发者

JSF - Forcing use of JSESSIONID in url for iFrame without 3rd party cookie support

HI all! I am working on a JAVA/JSF app that runs within an iFrame. The client authenticates Outside of the iFrame, then redirects back to a page that contains the application inside of an iFrame. If the client has 3rd party cookies disabled, the iFrame will not be able to access the cookie, and it will never see the jsessionid.

What I would like to do is test for the cookie in the app, and if not found, redirect using JS to开发者_运维知识库 the current page, with ;jsessionid appended to the end. I tried that with

;jsessionid=#{session.getId()}

Which looked OK...but would never maintain the current session. I then added an

<h:form><h:commandButton/></h:form>

to the page, turned off cookies, viewed the page in a browser, and saw that the jsessionid listed on the form was different than the one provided by session.getId().

My question is this......how can I get the correct jsessionid, the one that would be part of the form?

Thanks! Mason

--Update-- I should mention that this is on the same domain, webserver, and application. an and the #{session.getId()} on the same page will return a different jsessionid at the same time.


Sessions are by default domain- and context bound. Your issue indicates that the page which the iframe is serving runs at a different domain and/or context.

If the page in the iframe runs at a different domain, then you'll have to write a "local" servlet which acts as a proxy with help of java.net.URLConnection or Apache HttpClient and let the iframe link to that instead.

If the page in the iframe runs at same domain but at a different context (and runs at same webserver), then you need to configure the server to share the same session among all running webapps. How to do that exactly depends on the server in question. If it's Tomcat or a clone/fork, then check the emptySessionPath attribute of the HTTP connector.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜