When a user open the broser and done some work or some change and then close the browser then
it will be stored in cookie and also called the session time in which user access the browser.You can get session ID in jsp by using session.getId() and can set the session user by using session.setAttribute("Session",setsession),
When user does their work complete and want to close browser,It is called expire or destroy the session.You can find the session starting and ending using session.getCreationTime() and session.getLastAccessedTime() respactively.
JSP Stores and Retrieves Session Variables as thje following:

<% @page import = "java.util.Date" session="true"%>
<html>
<body>
<p>JSP (java server page) are required following</p>
String name="satya";
session.setAttribute("username",name);
String user=session.getAttribute("username");
out.println("Hello" +user);
Session ID of user in JSP : <%session.getId()%><br>
Started time of session in JSP<%new Date(session.getCreationTime())%><br>
expiry time of session in JSP<%new Date(session.getLastAccessedTime())%>
</body>
</html>