HttpSession interface

HttpSession interface

HttpSession interface provides a way to identify a user across more than one page request or visit to a Web site and to store information about that user.
The servlet container uses this interface to create a session between an HTTP client and an HTTP server.
The session persists for a specified time period, across more than one connection or page request from the user.
  • getSession() of HttpServletRequest  can be used to get HttpSession object.
  • invalidate() method can be used over HttpSession variable to close/destroy the session.
  • getId() method can be used to get the session id.

Example :


Leave a Reply

Your email address will not be published. Required fields are marked *