13.09.2016 Views

PHP and MySQL Web Development 4th Ed-tqw-_darksiderg

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

516 Chapter 23 Using Session Control in <strong>PHP</strong><br />

As you can see in Figure 23.3, you no longer have access to the persistent value of<br />

$_SESSION[‘sess_var’].<br />

Figure 23.3<br />

The session variable is no longer available.<br />

With some <strong>PHP</strong> versions prior to 4.3, you might encounter a bug when trying to unset<br />

elements of $HTTP_SESSION_VARS or $_SESSION. If you find that you are unable to unset<br />

elements (that is, they stay set), you can revert to using session_unregister() to clear<br />

these variables.<br />

You finish by calling session_destroy() to dispose of the session ID.<br />

Configuring Session Control<br />

There is a set of configuration options for sessions that you can set in your php.ini file.<br />

Some of the more useful options, <strong>and</strong> a description of each, are shown in Table 23.1.<br />

Table 23.1 Session Configuration Options<br />

Option Name Default Effect<br />

session.auto_start 0 (disabled) Automatically starts sessions.<br />

session.cache_expire 180 Sets time-to-live for cached session pages, in<br />

minutes.<br />

session.cookie_domain none Specifies the domain to set in the session<br />

cookie.<br />

session.cookie_lifetime 0 Sets how long the session ID cookie will<br />

last on the user’s machine.The default, 0,<br />

will last until the browser is closed.<br />

session.cookie_path / Specifies the path to set in the session<br />

cookie.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!