Class SessionHelper


  • @Immutable
    public final class SessionHelper
    extends Object
    HTTP session utilities.
    Author:
    Philip Helger
    • Method Detail

      • safeInvalidateSession

        @Nonnull
        public static com.helger.commons.state.EChange safeInvalidateSession​(@Nullable
                                                                             jakarta.servlet.http.HttpSession aSession)
        Invalidate the session if the session is still active.
        Parameters:
        aSession - The session to be invalidated. May be null.
        Returns:
        EChange.CHANGED if the session was invalidated, EChange.UNCHANGED otherwise.
      • getAllAttributes

        @Nonnull
        public static Enumeration<String> getAllAttributes​(@Nonnull
                                                           jakarta.servlet.http.HttpSession aSession)
        Get all attribute names present in the specified session.
        Parameters:
        aSession - The session to use. May not be null.
        Returns:
        Never null.
      • safeRenewSession

        @Nonnull
        public static jakarta.servlet.http.HttpSession safeRenewSession​(@Nonnull
                                                                        jakarta.servlet.http.HttpServletRequest aHttpRequest)
        Invalidate the session of the specified request (if any) and create a new session.
        Parameters:
        aHttpRequest - The HTTP request to use. May not be null.
        Returns:
        The new HttpSession to use. Never null.