From the course: Java EE: Servlets and JavaServer Pages (JSP)

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Cookies for session management

Cookies for session management

From the course: Java EE: Servlets and JavaServer Pages (JSP)

Start my 1-month free trial

Cookies for session management

- [Narrator] Now let's understand how is the session ID exchanged through cookies. Firstly, what are cookies? Cookies are small pieces of bits of information that are stored in the browser software. They could be information pertaining to the user or the application, et cetera. So let's understand how is a session ID generated and then how is it exchanged between the client and server via these cookies. Let's say the client comes in with the first request. Now the server will understand that is a new user because it did not receive any session ID from the client. So it will generate a new session ID for this new user. After that, it creates an object of the cookie class. Cookie is an API available to you under the servlet's specification. Once it creates an instance of the cookie, the server is going to stuff that session ID into the cookie object and write it as a part of the response. If you recall in one of our previous videos, when we saw the HTTP servlet response API we had seen…

Contents