Interface CookieManager


  • public interface CookieManager
    Cookie Manager. A cookie is stored on client and passed to server for every request. A cookie created by a subsystem instance will be passed to its own instance only.
    Since:
    3.4
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int SECONDS_PER_DAY
      Constant: seconds per day.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void createCookie​(java.lang.String name, java.lang.String value)
      Create a cookie with default age (10 years), and add it to response.
      void createCookie​(java.lang.String name, java.lang.String value, int cookieAge, boolean force, boolean addCookie)
      Create a cookie with the name and value.
      void deleteCookie​(java.lang.String cookieName)
      Delete the cookie with the name.
      void flushCookies()
      Flush all cookies to client side for non-partial request.
      int getCookieAge​(java.lang.String cookieName)
      Get cookie age in seconds.
      java.lang.String getCookieValue​(java.lang.String cookieName)
      Get cookie value.
    • Field Detail

      • SECONDS_PER_DAY

        static final int SECONDS_PER_DAY
        Constant: seconds per day.
        Since:
        5.14
        See Also:
        Constant Field Values
    • Method Detail

      • createCookie

        void createCookie​(java.lang.String name,
                          java.lang.String value)
        Create a cookie with default age (10 years), and add it to response.
        Parameters:
        name - cookie name
        value - cookie value
      • createCookie

        void createCookie​(java.lang.String name,
                          java.lang.String value,
                          int cookieAge,
                          boolean force,
                          boolean addCookie)
        Create a cookie with the name and value. The value will be encoded using URLEncoder.encode(String, String) with UTF-8 encoding.

        If force is true, create a new cookie overriding existing cookie. If force is false, override existing cookie with the same name but different value(case sensitive).

        Parameters:
        name - cookie name
        value - cookie value
        cookieAge - cookie age in seconds
        force - whether to create new cookie if there is an existing cookie with the same name and value.
        addCookie - whether to add the created cookie to response
      • getCookieValue

        java.lang.String getCookieValue​(java.lang.String cookieName)
        Get cookie value.
        Parameters:
        cookieName - cookie name
        Returns:
        cookie value
      • getCookieAge

        int getCookieAge​(java.lang.String cookieName)
        Get cookie age in seconds.
        Parameters:
        cookieName - cookie name
        Returns:
        age in seconds
        Since:
        5.14
      • deleteCookie

        void deleteCookie​(java.lang.String cookieName)
        Delete the cookie with the name.
        Parameters:
        cookieName - cookie name
      • flushCookies

        void flushCookies()
                   throws java.io.IOException
        Flush all cookies to client side for non-partial request.
        Throws:
        java.io.IOException - throw if a I/O error occurs
        See Also:
        RequestHelper.isPartial()