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


Copyright 2010 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK