One of the many very useful additions to PHP is built-in session support. Because HTTP is in itself a stateless protocol—in other words, nothing can be remembered about the user's history without some assistance—developers use different techniques such as cookies and sessions to create a sense of what the user has experienced. Where the user has been, the values of variables, and so forth can be stored on the server and associated with the user. A session, in short, is like a log of a user's visit to a site.

Previously, to create sessions, a programmer had to write an entire library of code that created a unique session name, stored information in a database or text file, sent and read a cookie, and retrieved the stored data. Even though ...

Get PHP Advanced for the World Wide Web: Visual QuickPro Guide 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.