Using Sessions

One of the many very useful additions to PHP as of version 4 is built-in session support. The premise of a session is that data is stored on the server, not in the Web browser, and a session identifier is used to locate a particular user’s record (session data).

Previous to PHP 4, to create sessions, a programmer had to write an entire library of code that created a unique session ID, stored information in a database or text file, sent and read a cookie, and retrieved the stored data. Even though the PHP Base Library (Figure 7.12) simplified this process some, PHP 4’s session support is a wonderful addition.

Figure 7.12. The PHP Base Library, or PHPLib, available at http://phplib.sourceforge.net, allowed developers to use sessions ...

Get PHP and MySQL for Dynamic Web Sites: Visual QuickPro Guide 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.