You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Martin A <wm...@gmail.com> on 2012/03/06 13:25:01 UTC

How to get WebSession by Session ID

Hello,
I'm developing a web application that is about to be displayed within a
Facebook canvas page (app page). I have a problem which comes up whenever a
user tries to make a payment through the app. Due to the usage of Facebook
JS API and Facebook payments API it looks to me like the request made by
Facebook is not via the user's http session (maybe due to security reasons)
and therefore a new web session is created, which, of course, lacks all
data that I've previously held for the user.

The way I use to get the session is Session.get(). To avoid the current
problem and still use the same session, I wonder if I can put the session
ID in the call parameters and later retrieve the same session by its ID. I
looked at Wicket's SessionStore, but didn't see way to get a session by id.
Would you assist me on how to do that?

Best regards,
Martin

Re: How to get WebSession by Session ID

Posted by Martin A <wm...@gmail.com>.
Hi, Dan,
Thanks for your prompt response,

I also had in mind that type of workaround, so obviously I don't have much
options here :)

Best regards,
Martin

On Tue, Mar 6, 2012 at 5:58 PM, Dan Retzlaff <dr...@gmail.com> wrote:

> Hi Martin,
>
> The Wicket Session is stored in the HttpSession, and the servlet spec does
> not allow retrieving HttpSessions by ID. You may need to store the relevant
> data in a more accessible location.
>
> For a simple non-distributed application (single server), you might just
> put a map keyed by session ID into the servlet context attribute, with a
> session listener to clear entries on expiration. See
> servlet's HttpSession#getServletContext().setAttribute(name, object) and
> Wicket's ISessionStore#registerUnboundListener.
>
> Dan
>
> On Tue, Mar 6, 2012 at 4:25 AM, Martin A <wm...@gmail.com> wrote:
>
> > Hello,
> > I'm developing a web application that is about to be displayed within a
> > Facebook canvas page (app page). I have a problem which comes up
> whenever a
> > user tries to make a payment through the app. Due to the usage of
> Facebook
> > JS API and Facebook payments API it looks to me like the request made by
> > Facebook is not via the user's http session (maybe due to security
> reasons)
> > and therefore a new web session is created, which, of course, lacks all
> > data that I've previously held for the user.
> >
> > The way I use to get the session is Session.get(). To avoid the current
> > problem and still use the same session, I wonder if I can put the session
> > ID in the call parameters and later retrieve the same session by its ID.
> I
> > looked at Wicket's SessionStore, but didn't see way to get a session by
> id.
> > Would you assist me on how to do that?
> >
> > Best regards,
> > Martin
> >
>

Re: How to get WebSession by Session ID

Posted by Dan Retzlaff <dr...@gmail.com>.
Hi Martin,

The Wicket Session is stored in the HttpSession, and the servlet spec does
not allow retrieving HttpSessions by ID. You may need to store the relevant
data in a more accessible location.

For a simple non-distributed application (single server), you might just
put a map keyed by session ID into the servlet context attribute, with a
session listener to clear entries on expiration. See
servlet's HttpSession#getServletContext().setAttribute(name, object) and
Wicket's ISessionStore#registerUnboundListener.

Dan

On Tue, Mar 6, 2012 at 4:25 AM, Martin A <wm...@gmail.com> wrote:

> Hello,
> I'm developing a web application that is about to be displayed within a
> Facebook canvas page (app page). I have a problem which comes up whenever a
> user tries to make a payment through the app. Due to the usage of Facebook
> JS API and Facebook payments API it looks to me like the request made by
> Facebook is not via the user's http session (maybe due to security reasons)
> and therefore a new web session is created, which, of course, lacks all
> data that I've previously held for the user.
>
> The way I use to get the session is Session.get(). To avoid the current
> problem and still use the same session, I wonder if I can put the session
> ID in the call parameters and later retrieve the same session by its ID. I
> looked at Wicket's SessionStore, but didn't see way to get a session by id.
> Would you assist me on how to do that?
>
> Best regards,
> Martin
>