Class CookieUtil

java.lang.Object
com.saperion.ngc.util.CookieUtil

public final class CookieUtil extends Object
Utility class to store and read from cookies.
  • Field Details

    • SA_WEB_CLIENT_LAST_USER

      public static final String SA_WEB_CLIENT_LAST_USER
      Name of the user-cookie.
      See Also:
    • SA_WEB_CLIENT_LAST_USER_LANGUAGE

      public static final String SA_WEB_CLIENT_LAST_USER_LANGUAGE
      Name of the user-language-cookie.
      See Also:
  • Method Details

    • setCookie

      public static void setCookie(String name, String content, int maxAge)
      Sets a new cookie.
      Parameters:
      name - cookie name
      content - cookie content
      maxAge - maximum age of this cookie in seconds
    • getCookieContent

      public static String getCookieContent(String cookieName)
      Reads from a cookie.
      Parameters:
      cookieName - name of the cookie to read from
      Returns:
      cookie content as string or null, if no cookie with the specified name was found
    • storeLastUser

      public static void storeLastUser()
      Stores a cookie with information about the last active user. The cookie contains a string like 'Username;Mandant;Type'.
    • getLastLoginFromCookie

      public static AuthenticationInformation getLastLoginFromCookie()
      Reads the last active user from a cookie. Will NOT retrieve the password.
      Returns:
      last user or null if cookie was not found or contains invalid content
    • storeLastLocale

      public static void storeLastLocale(String locale)
      Stores a cookie with information about the last active user Locale. The cookie contains a string like 'Locale'.
      Parameters:
      locale - like de_DE or en_US
    • getLastLocaleFromCookie

      public static String getLastLocaleFromCookie()
      Reads the last active Locale from a cookie.
      Returns:
      last locale or null if cookie was not found or contains invalid content