Package mg.emberframework.core.data
Class Session
java.lang.Object
mg.emberframework.core.data.Session
Wraps an
HttpSession
to manage session data in the framework.
This class provides methods to add, retrieve, and remove session attributes, as well as clear the session entirely.
- Since:
- 1.0.0
- Version:
- 1.0.0
- Author:
- Sandratra NIAINA
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds an attribute to the session.void
clear()
Clears the session, invalidating it.Retrieves an attribute from the session.jakarta.servlet.http.HttpSession
Gets the underlying HTTP session.void
Removes an attribute from the session.void
setUserSession
(jakarta.servlet.http.HttpSession userSession) Sets the underlying HTTP session.
-
Constructor Details
-
Session
public Session()Default constructor. -
Session
public Session(jakarta.servlet.http.HttpSession session) Constructs a session with an existingHttpSession
.- Parameters:
session
- the HTTP session to wrap
-
-
Method Details
-
get
Retrieves an attribute from the session.- Parameters:
name
- the attribute name- Returns:
- the attribute value, or null if not found
-
add
Adds an attribute to the session.- Parameters:
name
- the attribute namevalue
- the attribute value
-
remove
Removes an attribute from the session.- Parameters:
name
- the attribute name
-
clear
public void clear()Clears the session, invalidating it. -
getUserSession
public jakarta.servlet.http.HttpSession getUserSession()Gets the underlying HTTP session.- Returns:
- the session object
-
setUserSession
public void setUserSession(jakarta.servlet.http.HttpSession userSession) Sets the underlying HTTP session.- Parameters:
userSession
- the session to set
-