5.1. Displaying the Shopping Cart
At some point in any eCommerce site, site visitors add products to their shopping carts and then try to check out. By the end of the chapter, you'll have a working shopping cart (but no checkout function, as you'll need to confer with the client about this).
The approach you're going to take with Claudia's Kids is a simple, straightforward approach that makes use of both CodeIgniter's session object and native PHP sessions. If you're used to working with PHP sessions, you might be tempted to think that CodeIgniter's session object is the same thing. CodeIgniter sessions are different from PHP sessions, acting just like cookies. They can be encrypted and can store serialized data that are automatically created or updated as needed.
To use CodeIgniter sessions, all you need to do is load the library. In this case, you've already loaded the Session library in the autoloader.php file (in Chapter 2), so all you have to do now is use the appropriate functions.
Because CodeIgniter sessions are cookies, you have the same limitations as you do with cookies in general. For example, cookies can be tampered with by the end-user. This makes CodeIgniter sessions (even if the data in them are encrypted) hard to trust. Another limitation is the fact that a session cookie only holds 4 KB (kilobytes) of data. It is possible for someone to fill up their session cookie either accidentally or with malicious intent.
You're going to combine the two approaches. Your ...
Get Professional CodeIgniter® 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.