O'Reilly logo

Professional CodeIgniter® by Thomas Myer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required