The session is a global variable and is the proxy of the browser thread on the server side. As soon as the Web service program is open, the session will exist, and when you first visit, the session will automatically assign you one session ID, so the session is newly established, so Session.isnew () is true. When you refresh the page, the session ID persists (Session.getid () unchanged) and does not disappear, so Session.isnew () is false. Unless you close the Web site you are visiting, or close the session (Session.invalidate ()), it Disappears (Session.getid () is changed) and IsNew () is true.
Two methods Session.isnew () to determine if it is a new session
Session.getid () get this session ID
Session.isnew () is true when all browsers are closed and then logged in again
Session.isnew () is false when a new browser is opened each time with a different user login. Session.getid () is the same.
That is, the session ID is equivalent to the ID assigned by the Web server to this browser process when a browser process (not a thread) is opened
Common methods:
Long create_time = Session.getcreationtime (); Session creation Time
Long access_time = Session.getlastaccessedtime ();//session Last access time
Print the attribute value in the session
Enumeration elements = Session.getattributenames ();
while (Elements.hasmoreelements ()) {
String id = (string) elements.nextelement ();
}
Response.setheader ("Refresh", "5;url=/session_filter_listener/index.jsp");//Refresh every 5 seconds and navigate to index.jsp