Example usage for org.apache.wicket Session replaceSession

List of usage examples for org.apache.wicket Session replaceSession

Introduction

In this page you can find the example usage for org.apache.wicket Session replaceSession.

Prototype

public void replaceSession() 

Source Link

Document

Replaces the underlying (Web)Session, invalidating the current one and creating a new one.

Usage

From source file:fiftyfive.wicket.shiro.ShiroWicketPlugin.java

License:Apache License

/**
 * Called by {@link LogoutPage} once the user has been logged out.
 * The default implementation adds a feedback message to the session that says
 * "you have been logged out". To override or localize this message,
 * define {@code loggedOut} in your application properties. You can disable the
 * message entirely by defining {@code loggedOut} as an empty string.
 *//*from   w w w. ja v  a  2  s  .  c om*/
public void onLoggedOut() {
    String message = getLocalizedMessage(LOGGED_OUT_MESSAGE_KEY, "You have been logged out.");
    if (message != null && !message.matches("^\\s*$")) {
        // Invalidate current session and create a new one.
        // We need a new session because otherwise our feedback message won't "stick".
        Session session = Session.get();
        session.replaceSession();

        // Add localized "you have been logged out" message to session
        session.info(message);
    }
}