Class Session

java.lang.Object
mg.emberframework.core.data.Session

public class Session extends Object
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
    Constructor
    Description
    Default constructor.
    Session(jakarta.servlet.http.HttpSession session)
    Constructs a session with an existing HttpSession.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    add(String name, Object value)
    Adds an attribute to the session.
    void
    Clears the session, invalidating it.
    get(String name)
    Retrieves an attribute from the session.
    jakarta.servlet.http.HttpSession
    Gets the underlying HTTP session.
    void
    remove(String name)
    Removes an attribute from the session.
    void
    setUserSession(jakarta.servlet.http.HttpSession userSession)
    Sets the underlying HTTP session.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • Session

      public Session()
      Default constructor.
    • Session

      public Session(jakarta.servlet.http.HttpSession session)
      Constructs a session with an existing HttpSession.
      Parameters:
      session - the HTTP session to wrap
  • Method Details

    • get

      public Object get(String name)
      Retrieves an attribute from the session.
      Parameters:
      name - the attribute name
      Returns:
      the attribute value, or null if not found
    • add

      public void add(String name, Object value)
      Adds an attribute to the session.
      Parameters:
      name - the attribute name
      value - the attribute value
    • remove

      public void remove(String name)
      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