Specifications

LISTING 20.3 page3.phpβ€”Ending the Session
<?
session_start();
echo β€œThe content of \$sess_var is $sess_var<br>”;
session_destroy();
?>
As you can see in Figure 20.3, we no longer have access to the persistent value of $sess_var.
Using Session Control in PHP
C
HAPTER 20
20
USING SESSION
C
ONTROL IN
PHP
437
FIGURE 20.3
The deregistered variable is no longer available.
We finish by calling session_destroy() to dispose of the session ID.
Configuring Session Control
There is a set of configuration options for sessions that you can set in your php.ini file. Some
of the more useful options, and a description of each, are shown in Table 20.1.
TABLE 20.1 Session Configuration Options
Option Name Default Effect
session.auto_start 0 (disabled) Automatically starts sessions.
session.cache_expire 180 Sets time-to-live for cached session
pages, in minutes.
session.cookie_domain none Domain to set in session cookie.
session.cookie_lifetime 0 How long the session ID cookie will last
on the user’s machine. The default, 0,
will last until the browser is closed.
25 7842 CH20 3/6/01 3:42 PM Page 437