Search code examples
apache-flexblazeds

HttpSession Session ID different to FlexSession ID


I have a Flex application which is served via a JSP page. In this page I output the session ID using HttpSession when the page is loaded:

System.out.println("Session ID: " + session.getId());

In a very simple remote object hosted in BlazeDS (called from the flex application using an AMF Channel and standard RemoteObject functionality) I also output the session ID but this time using FlexSession (which as I understand is supposed to wrap around HttpSession).

System.out.println("FlexSession ID: " + FlexContext.getFlexSession().getId());

I would expect both IDs to be the same but this is not the case. The session IDs differ which is causing problems as there is data stored in the HttpSession which I need to be able to access from my remote objects within BlazeDS.

I've exhausted the reading material on BlazeDS and FlexClient/FlexSession/FlexContext but can't see why the FlexSession is not being linked to the HttpSession. Any pointers greatly appreciated.

I feel I must be missing something fundemental here, am I accessing the


Solution

  • Thanks to both answers above I finally found the root cause and thought I'd share it on here.

    The reason for differing session IDs was to do with the use of SSL for authentication and the use of AMF Channel rather than Secure AMF. Using the channel for the first time caused a new session to be created (hence the different ID) as the existing session related to the secure version of the site.

    Silly configuration mistake but worth passing on - make sure that if using SSL that you're also using Secure AMF connecting to the secure endpoint rather than standard AMF or you'll run into the same session ID problems I faced.