Class Session


  • public class Session
    extends Object
    Server side Session.
    • Constructor Detail

      • Session

        public Session​(String id,
                       long expiration)
        Constructs a Session.
        Parameters:
        id - the identifier of the session.
        expiration - the expiration date of the session.
    • Method Detail

      • getId

        public String getId()
        Gets the id.
        Returns:
        the id.
      • getExpiration

        public long getExpiration()
        Gets the expiration.
        Returns:
        the expiration.
      • hasExpired

        public boolean hasExpired()
        Checks whether the session has expired or not.
        Returns:
        true if the session has expired, false otherwise.
      • setAttribute

        public void setAttribute​(String name,
                                 String value)
        Set a session attribute.
        Parameters:
        name - attribute name
        value - attribute value
      • getAttribute

        @Nullable
        public String getAttribute​(String name)
        Get a session attribute.
        Parameters:
        name - attribute name
        Returns:
        return attribute mapped to this name if it exists, null otherwise
      • removeAttribute

        @Nullable
        public String removeAttribute​(String name)
        Remove an attribute from this session.
        Parameters:
        name - attribute name
        Returns:
        the previous value associated with name, or null if there was no mapping for name.
      • getAttributesNames

        public Set<String> getAttributesNames()
        Gets the set of the session attributes names.
        Returns:
        the set of the session attributes names
      • setExpiration

        protected void setExpiration​(long expiration)
        Sets the expiration.
        Parameters:
        expiration - the expiration to set in millis.