Class HttpSessionHandler
- java.lang.Object
-
- com.kttdevelopment.simplehttpserver.HttpSessionHandler
-
public class HttpSessionHandler extends Object
This class assignsHttpSessionto every client.- Since:
- 03.03.00
- Version:
- 03.05.00
- Author:
- Ktt Development
-
-
Constructor Summary
Constructors Constructor Description HttpSessionHandler()Creates a session handler using the cookie__session-id.HttpSessionHandler(String cookie)Creates a session handler, storing the id at the specified cookie.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringassignSessionID(HttpExchange exchange)Assigns a session id to a client.HttpSessiongetSession(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 usingHttpExchange.sendResponseHeaders(int, long).StringtoString()
-
-
-
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 usingHttpExchange.sendResponseHeaders(int, long).- Parameters:
exchange- http exchange- Returns:
- session associated with the exchange
- Since:
- 03.03.00
-
-