What is Session Tracking?

Session Tracking tracks a user’s requests and maintains their state. It is a mechanism used to store information on specific users and in order to recognize these user’s requests when they connect to the web server.

HTTP is a stateless protocol where each request to the server is treated like a new request. However, there are ways to maintain the data for a particular user in order to serve them specific content.

There are several ways to track user sessions including cookies, URL rewriting, and hidden form fields.

If session tracking is not used, request 2 is treated as a new request without the server recognizing that it is from the same user.

Cookies

A cookie is a unique ID assigned to clients when they first visit a website. Whenever this client connects to the server again, it will send the cookie that was given earlier by the server. The server will then recognize that it is the same user.

Hidden form fields

Hidden form fields are used to insert information, e.g., a unique ID when sending a request to the server. These fields are not directly visible to the user, but each time a request is sent to the server, the unique ID is also sent as a part of the request, enabling the server to recognize the client.

URL rewriting

URL rewriting adds a unique session ID in the URL itself when it sends a request to the server. Since the session ID is part of the URL, it is directly visible to users. For example:

www.educative.io/edpresso;sessionid=123456

Free Resources