Package org.example.util
Class UserSession
java.lang.Object
org.example.util.UserSession
Global session manager to track the currently authenticated user.
Implemented as a thread-safe singleton-like utility.
-
Method Summary
Modifier and TypeMethodDescriptionstatic voidClears the current session (logout).static Stringstatic booleanChecks if a user is currently authenticated.static voidsetInstance(String nickname) Initializes the session with a user's nickname.
-
Method Details
-
setInstance
Initializes the session with a user's nickname.- Parameters:
nickname- The nickname of the logged-in user.
-
getCurrentUserNickname
- Returns:
- The nickname of the current user, or null if no one is logged in.
-
isLoggedIn
public static boolean isLoggedIn()Checks if a user is currently authenticated.- Returns:
- true if session is active.
-
cleanUserSession
public static void cleanUserSession()Clears the current session (logout).
-