Class ContextSessionPersistence


  • public class ContextSessionPersistence
    extends java.lang.Object
    • Constructor Detail

      • ContextSessionPersistence

        public ContextSessionPersistence()
    • Method Detail

      • get

        public static java.lang.String get​(SlingHttpServletRequest request,
                                           java.lang.String key)
        Returns the value from the default session persistence cookie for the specified key.
        Parameters:
        request - The SlingHttpServletRequest
        key - Key
        Returns:
        Value or an empty string
      • get

        public static java.lang.String get​(SlingHttpServletRequest request,
                                           java.lang.String key,
                                           java.lang.String cookieName)
        Returns the value from the specified cookieName cookie for the specified key.
        Parameters:
        request - The SlingHttpServletRequest
        key - Key
        cookieName - Cookie name
        Returns:
        Value or an empty string
      • getMap

        public static java.lang.String getMap​(SlingHttpServletRequest request)
        Returns a key/value map of the default session persistence cookie.
        Parameters:
        request - The SlingHttpServletRequest
        Returns:
        Map with key/value pairs
      • getMap

        public static java.lang.String getMap​(SlingHttpServletRequest request,
                                              java.lang.String cookieName)
        Returns a key/value map of named cookie.
        Parameters:
        request - The SlingHTTPServletRequest
        cookieName - Cookie name
        Returns:
        Map with key/value pairs
      • put

        public static void put​(SlingHttpServletRequest request,
                               SlingHttpServletResponse response,
                               java.lang.String key,
                               java.lang.String value)
        Add a name/value pair to the default session persistence cookie.
        Parameters:
        request - The SlingHTTPServletRequest
        response - The SlingHTTPServletResponse
        key - Key
        value - Value
      • put

        public static void put​(SlingHttpServletRequest request,
                               SlingHttpServletResponse response,
                               java.lang.String key,
                               java.lang.String value,
                               java.lang.String cookieName)
        Add a name/value pair to a named cookie.
        Parameters:
        request - The SlingHTTPServletRequest
        response - The SlingHTTPServletResponse
        key - Key
        value - Value
        cookieName - Cookie name
      • getStore

        public static java.util.Map<java.lang.String,​java.lang.String> getStore​(SlingHttpServletRequest request,
                                                                                      java.lang.String key)
        Return a single store (by its key) from the default session persistence cookie.
        Parameters:
        request - The SlingHttpServletRequest
        key - Key referencing the store
        Returns:
        the store
      • getStore

        public static java.util.Map<java.lang.String,​java.lang.String> getStore​(SlingHttpServletRequest request,
                                                                                      java.lang.String key,
                                                                                      java.lang.String cookieName)
        Return a single store (by its key) from a named cookie.
        Parameters:
        request - The SlingHttpServletRequest
        key - Key referencing the store
        cookieName - Cookie name
        Returns:
        the store
      • putStores

        public static void putStores​(SlingHttpServletRequest request,
                                     SlingHttpServletResponse response,
                                     java.util.Map<java.lang.String,​java.util.Map<java.lang.String,​java.lang.String>> stores,
                                     java.lang.String cookieName)
        Put multiple stores at once without overwriting stores previously put to response. The method takes a map of stores where the key corresponds to the store key.
        Parameters:
        request - The request
        response - The response
        stores - The map of stores
        cookieName - The cookie's name
      • getCookieName

        public static java.lang.String getCookieName()
        Return the name of the default session persistence cookie.
        Returns:
        Cookie name
      • getCookieName

        public static java.lang.String getCookieName​(SlingSettingsService settingsService)
        Deprecated.
        since 5.6. Use getCookieName() instead.
        Return the name of the cookie.
        Parameters:
        settingsService - The SlingSettingsService
        Returns:
        Cookie name
      • getCookieName

        public static java.lang.String getCookieName​(java.lang.String cookiePrefix,
                                                     SlingSettingsService settingsService)
        Deprecated.
        since 5.6. Use getCookieName() instead.
        Return the name of the cookie.
        Parameters:
        cookiePrefix - The cookie prefix
        settingsService - The SlingSettingsService
        Returns:
        Cookie name