Hour 20. Saving State with Session Functions

What You’ll Learn in This Hour:

  • What session variables are and how they work

  • How to start or resume a session

  • How to work with variables in a session

  • How to destroy a session

  • How to unset session variables

In the previous hour, we looked at saving state from page to page, using a cookie or a query string. Once again, PHP is one step ahead of us. As of PHP 4, functions for managing user sessions were built in to the language. These use techniques similar to those explored in the previous hour but build them into the language, making saving state as easy as calling a function.

Get Sams Teach Yourself PHP in 24 Hours, Third 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.