Class HttpSessionHandler


  • public class HttpSessionHandler
    extends Object
    This class assigns HttpSession to every client.
    Since:
    03.03.00
    Version:
    03.05.00
    Author:
    Ktt Development
    • Constructor Detail

      • HttpSessionHandler

        public HttpSessionHandler()
        Creates a session handler using the cookie __session-id.
        Since:
        03.03.00
      • HttpSessionHandler

        public HttpSessionHandler​(String cookie)
        Creates a session handler, storing the id at the specified cookie.
        Parameters:
        cookie - cookie to store session id
        Since:
        03.03.00
    • Method Detail

      • assignSessionID

        public String assignSessionID​(HttpExchange exchange)
        Assigns a session id to a client. It is important to make sure duplicate ids do not occur.
        Parameters:
        exchange - http exchange
        Returns:
        session id
        Since:
        03.03.00
      • getSession

        public final HttpSession getSession​(HttpExchange exchange)
        Returns the session of the client or assigns one if it does not yet have one Session will only be saved client side if the exchange headers are sent using HttpExchange.sendResponseHeaders(int, long).
        Parameters:
        exchange - http exchange
        Returns:
        session associated with the exchange
        Since:
        03.03.00