9. Cookies and Sessions

The Hypertext Transfer Protocol (HTTP) is a stateless technology, meaning that each individual HTML page is an unrelated entity. HTTP has no method for tracking users or retaining variables as a person traverses a site. Using a Web scripting language like PHP, you can overcome the statelessness of the Web. You have a few options to choose from, the most popular two being cookies and sessions.

Prior to the existence of cookies, surfing a Web site was a trip without a history. Although your browser tracked the pages you visited, allowing you to use the back button to return to previously visited pages, the server kept no record of who had seen what. Without the server being able to track a user, there can be no shopping ...

Get PHP and MySQL for Dynamic Web Sites: Visual Quickpro Guide, Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.