Specifications
else
{
// if they weren’t logged in but came to this page somehow
echo “You were not logged in, and so have not been logged out.<br>”
;
}
?>
The code’s very simple, but we do a little fancy footwork. We start a session, store the user’s
old username, deregister the valid user variable, and destroy the session. We then give the user
a message that will be different if she was logged out, could not be logged out, or was not
logged in to begin with.
This simple set of scripts will form the basis for a lot of the work we’ll do in later chapters.
Further Reading
Native sessions are new to PHP 4, but sessions have been provided by PHPLib for a while.
The best things to read for more information are the PHPLib homepage and the cookies speci-
fication. We’ve listed both these URLs earlier in the chapter, but we’ll reprint them here for
reference:
http://phplib.netuse.de/index.php3
http://home.netscape.com/newsref/std/cookie_spec.html
Next
We’re almost finished with this section of the book.
Before we move on to the projects, we’ll briefly discuss some of the useful odds and ends of
PHP that we haven’t covered elsewhere.
Using Session Control in PHP
C
HAPTER 20
20
USING SESSION
C
ONTROL IN
PHP
445
LISTING 20.6 Continued
25 7842 CH20 3/6/01 3:42 PM Page 445










