• Both sessions and cookies are useful ways of storing data across web pages, and have their own advantages: sessions are more secure, and cookies can survive even after the user closes their browser.

  • You can rewrite the session system with PHP so that your session data is stored wherever you want - perfect for large, distributed server farms.

  • Unless you are using output buffering, cookies need to be sent before the main body of your page in order to comply with the HTTP protocol.

  • To store complex data types such as arrays and objects in a cookie or session you can serialize() to explicitly make them a string first.


Next chapter: Exercises >>

Previous chapter: Storing complex data types

Jump to:


Home: Table of Contents

Follow us on or Twitter

Username:   Password:
Create Account | About TuxRadar