Checking session data
You can check whether a variable has been set in a user's session using the function isset(), as you would a normal variable. Because the $_SESSION superglobal is only initialised once session_start() has been called, you need to call session_start() before using isset() on a session variable. For example:
<?php
session_start();
if (isset($_SESSION['FirstName'])) {
/// your code here
}
?>
You can, of course, also use the empty() function with session data, or indeed any other function - the $_SESSION array and its data can be used like any other array.
Next chapter: Files vs. Databases >>
Previous chapter: Ending a session
Jump to:
Home: Table of Contents



Copyright 2012 Future Publishing Limited (company
registered number 2008885), a company registered
in England and Wales whose registered office is at
Beauford Court, 30 Monmouth Street, Bath, BA1 2BW, UK