# Stateful Web Applications

HyperText Transfer Protocol (HTTP) is a stateless protocol. However most of the web applications we use nowadays needs to maintain a certain state, as otherwise we would have to login each time we request a new page.

There are several techniques a web developer can use to simulate a stateful experience.

## Sessions

To maintain a sense a statefulness, web servers can send a unique token that is sent back by the user’s browser. This token is referred to as session identifier.

Technically, each request is still stateless and do not know about the previous one, but the session id creates the illusion of a persistent connection between requests.

The server has to do some work to simulate statefulness. In particular, it has to parse the session id, check it it still valid (for security reason) and craft a personalized response for this request.

Responses from AJAX requests are processed by callbacks. A callback is a logic code passed to function to be executed after a certain event has happened; in this case, when the response is returned.