# Class SessionUtils

java.lang.Object
org.apache.catalina.manager.util.SessionUtils

public class SessionUtils extends Object
Utility methods on HttpSessions.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static long`
  `getInactiveTimeForSession(Session in_session)`
  Returns the time in milliseconds since the session was last accessed.
  `static long`
  `getTTLForSession(Session in_session)`
  Returns the remaining time-to-live for the session in milliseconds.
  `static long`
  `getUsedTimeForSession(Session in_session)`
  Returns the time in milliseconds that the session has been active.
  `static Locale`
  `guessLocaleFromSession(HttpSession in_session)`
  Try to get user locale from the session, if possible.
  `static Locale`
  `guessLocaleFromSession(Session in_session)`
  Try to get user locale from the session, if possible.
  `static Object`
  `guessUserFromSession(Session in_session)`
  Try to get user from the session, if possible.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### guessLocaleFromSession

    public static Locale guessLocaleFromSession(Session in_session)
    Try to get user locale from the session, if possible.
    Parameters:
      `in_session` - The session
    Returns:
      the locale, or `null` if it cannot be determined

  - ### guessLocaleFromSession

    public static Locale guessLocaleFromSession(HttpSession in_session)
    Try to get user locale from the session, if possible. Searches for Locale objects stored under known attribute names used by common frameworks (Struts, JSTL, Spring MVC), and falls back to iterating all session attributes if exactly one Locale is found.
    Parameters:
      `in_session` - The HTTP session
    Returns:
      the locale, or `null` if it cannot be determined

  - ### guessUserFromSession

    public static Object guessUserFromSession(Session in_session)
    Try to get user from the session, if possible.
    Parameters:
      `in_session` - The session
    Returns:
      the user

  - ### getUsedTimeForSession

    public static long getUsedTimeForSession(Session in_session)
    Returns the time in milliseconds that the session has been active.
    Parameters:
      `in_session` - The session
    Returns:
      the active time in milliseconds, or -1 if the session is invalidated

  - ### getTTLForSession

    public static long getTTLForSession(Session in_session)
    Returns the remaining time-to-live for the session in milliseconds.
    Parameters:
      `in_session` - The session
    Returns:
      the remaining TTL in milliseconds, or -1 if the session is invalidated

  - ### getInactiveTimeForSession

    public static long getInactiveTimeForSession(Session in_session)
    Returns the time in milliseconds since the session was last accessed.
    Parameters:
      `in_session` - The session
    Returns:
      the inactive time in milliseconds, or -1 if the session is invalidated