Chapter 6
Sessions and Carts
IN THIS CHAPTER
Storing data
Using cookies
Working with sessions
Playing with carts
In Chapter 3 of Book 2, I show you how to use the HTTP GET and POST methods to send data from one web page to another. Although they work fine for clicking links and submitting forms, they're somewhat impractical to use for sharing data between all the web pages in an application. To do that requires some other form of persistent data, someplace where you can temporarily store it so that your PHP programs can access the data at any time from any page. This is where sessions and carts help out. This chapter explains how they work, why you shouldn’t be afraid of them, and how to use them as another piece of your dynamic web applications.
Storing Persistent Data
Most dynamic web applications require some way of temporarily storing data while site visitors work their way through the application's web pages. I’m not talking about long-term storage of data (I cover that in Book 5). I’m talking about short-term storage of data that one web page stores and another web page ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access