Cookies to Implement Sessions Servlet

The purpose of this assignment was to:

The description and my solution of the Cookies to Implement Sessions Servlet -assignment can be viewed and/or downloaded at the bottom of this page.

What are Cookies?

Cookies are a small text files downloaded from servers with Web browsers onto visitors hard drives to store the visitors actions, usually in order to better customise their following visits.

Cookies can for example associate a visitor with a specific session.

Important About Cookies

A cookie is unique for the client computer, not the client account. If a computer is used by many this could be dangerous.

It's usually good practice to implement sessions with URL rewriting as well in case cookies are disabled in the client browser. This can be done with a session id.

Important about Session IDs

A Session id in the URL can be problematic for some search engine robots. To overcome this there are different ways to make URLs easier to read. I won't go in to it further, but mod_rewrite can be useful if Apache is used.

Why use Sessions?

Sessions are useful for grouping requests so that information can be maintained between an individual user requests.

This way the clients state can be maintained, e.g. a visitors shoppingcart can remember all it's items while a user is shopping.

Assignment Description

Create a servlet that set two cookies on clients making requests. One time-cookie(when the cookie was requested), and one name-cookie. The cookies should be valid/live for 3 hours.

My Solution, Assignment Files

Try the Cookies, Sessions servlet

«  Previous Next  »
Loading