This is one of the nasty parts of wicket.. very difficult to get rid
of a session. This is what I have come up with:

  public static void logout(RequestCycle requestCycle, Request request) {
    // flush session
    Session.unset();
    TakpApplication application = TakpApplication.get();
    ISessionStore sessionStore = application.getSessionStore();
    sessionStore.removeAttribute(request, Session.SESSION_ATTRIBUTE_NAME);
    TakpSession session = get();
    sessionStore.setAttribute(request, Session.SESSION_ATTRIBUTE_NAME, session);
    try {
      sessionField.set(requestCycle, session);
    } catch (Exception e) {
      throw new RuntimeException(e);
    }
  }

**
Martin


2009/7/29 Erik van Oosten <e.vanoos...@grons.nl>:
> Try this in a method of your WebSession subclass:
>
>       ((WebRequest)
> RequestCycle.get().getRequest()).getHttpServletRequest().getSession().invalidate();
>       // Bind forces a connect of the current Wicket session to the new HTTP
> session.
>       bind();
>
> Regards,
>   Erik.
>
>
> Matthias Keller wrote:
>>
>> Hi
>>
>> I'm writing our custom internal error handler which is supposed to
>> terminate the current session and create a new one (in order to pass over
>> the locale to the new session).
>>
>> I've stumbled upon the  Session.replaceSession()  method which, according
>> to the javadoc, should just exactly do that.
>> But when I call this method, nothing happens. The same session continues
>> to be used and no new session is being created at all?!
>>
>> I've got it to work by using:
>>
>>       Session newSession = getApplication().newSession(getRequest(),
>> getResponse());
>>       newSession.setLocale(getSession().getLocale());
>>       getSession().invalidateNow();
>>       Session.unset();
>>       newSession.replaceSession();
>>
>> But I think there must be something easier... ???!
>>
>> Thanks
>>
>> Matt
>>
>
> --
> Erik van Oosten
> http://day-to-day-stuff.blogspot.com/
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
> For additional commands, e-mail: users-h...@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to