Class Session


  • public class Session
    extends Object
    Author:
    svenkubiak
    • Constructor Detail

      • Session

        public Session()
    • Method Detail

      • create

        public static Session create()
      • withAuthenticity

        public Session withAuthenticity​(String authenticity)
      • invalidate

        public void invalidate()
        Invalidates the session by sending expiring the client cookie
      • hasContent

        public boolean hasContent()
        Checks if the session has at least one entry
        Returns:
        True if the session has at least one entry, false otherwise
      • get

        public String get​(String key)
        Retrieves a specific value from the session
        Parameters:
        key - The key
        Returns:
        The value or null if none present
      • getValues

        public Map<String,​String> getValues()
        Returns:
        All values of the session
      • getExpires

        public LocalDateTime getExpires()
        Returns:
        The expire date of the session
      • put

        public void put​(String key,
                        String value)
        Adds a value to the session, overwriting an existing value
        Parameters:
        key - The key to store the value
        value - The value to store
      • remove

        public void remove​(String key)
        Removes a value with a given key from the session
        Parameters:
        key - The key to remove
      • clear

        public void clear()
        Clears the complete session
      • hasChanges

        public boolean hasChanges()
        Returns:
        True if a session values has change, be removed or the session has been cleared, false otherwise
      • isInvalid

        public boolean isInvalid()
      • getAuthenticity

        public String getAuthenticity()
        Returns:
        The current authenticity token and marks the session as changed