10.5 SummaryThis is NOT the latest copy of this book; click here for the latest version.
-
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.
|
Want to see this stuff in print? PHP in a Nutshell takes the core topics covered here, adds in thousands of edits from the editorial team and myself, and combines them to make an unbeatable reference for PHP programmers at all levels.
My latest book has hundreds more tips on how to use PHP, Apache, and MySQL, plus Perl, Python, shell scripts, performance tuning, and more!
|