You want to use session storage for PHP scripts.
PHP 4 includes session managment. By default, it uses temporary files for backing store, but you can configure it to use MySQL instead.
PHP 4 includes a native session manager. This section shows how to
use it and how to extend it by implementing a storage module that
saves session data in MySQL. If your PHP configuration has both the
register_globals configuration directives
enabled, session variables will exist as global variables of the same
names in your script. (
track_vars is enabled
automatically for PHP 4.0.3 or later; for earlier versions, you
should enable it explicitly.) If
is not enabled, you’ll need to access session
variables as elements of the
global array or the
$_SESSION superglobal array.
This is less convenient than relying on
register_globals, but is also more secure. (Recipe 18.6 discusses PHP’s global and
superglobal arrays and the security implications of
PHP’s session management capabilities are based on a small set of functions, all of which are documented in the PHP manual. The following list describes those likely to be most useful for day-to-day session programming:
session_start ( )
Opens a session and extracts any variables previously stored in it, making them available in the script’s global namespace. For example, ...