6. Remembering Users (Cookies and Sessions)

Hypertext Transfer Protocol (HTTP) is a stateless protocol. Put simply, a client (Web browser) connects to a Web server, sends a request, and gets a response. Then, the connection is closed. The consequence is the next time the same client sends a request to the same Web server, it is a new request, so the Web server cannot identify the caller. This is, of course, a problem for applications in which state must be maintained (for instance, e-commerce applications with a shopping-cart functionality).

However, you can overcome this limitation in several ways. The basic idea is to send some information with the HTTP response; to try to achieve that, this information is sent back with all subsequent requests ...

Get PHP and MySQL™ Phrasebook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.