We will discuss why HTTP is designed as a stateless protocol and what will happen if it comes as stateful protocol. If HTTP is stateful protocol, multiple requests given by client to web application by a single connection will be used between browser window and web server across the multiple requests. This makes clients engage connection with web server for long time even though most of its connections are idle.
To overcome that problem, HTTP is given as stateless so that no client can engage connection with web server for a long time. Moreover, the connection will be closed automatically at the end of each request related to response generation. In the Internet environment since there is a chance of having huge amount of clients for each website it is recommended to have stateless behavior for http.
If web application is capable of remembering a client data during a session across the multiple requests, then that web application is called a stateful web application. In stateful web applications the web resource programs can use the data of previous request, while processing current request, that is while processing request2, it can use request1 data.
Even though HTTP is a stateless protocol we need to make our web applications stateful. For this we need to work with the following session tracking or session management techniques:
(1) Hidden form fields
(2) HTTP cookies
(3) HTTP session with cookies
(4) HTTP session with URL rewriting (recommended)
Session tracking/ session management is all about making web applications stateful by remembering client data across the multiple requests during a session