A Simple Session-Based Shopping Cart

The following example is a simple session-based shopping cart that allows users to add or remove items from their cart.

The application, as shown in Figure 2-3, first asks for the user's name and email address. Users are then brought to the main shopping page where they can add or remove items from their cart by modifying the quantity text field for each item and clicking the “Add Items” button.

Figure 2-3. session_cart.php Sign-In Screen

When the users have added at least one item, they are presented with a “Check Out” button. They can continue shopping or check out. This is shown in Figure 2-4.

Figure 2-4. ...

Get Advanced PHP for Web Professionals 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.