13.09.2016 Views

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Creating a Simple Session Example<br />

515<br />

Listing 23.2<br />

<br />

Next page<br />

After you call session_start(), the variable $_SESSION [‘sess_var’] is available with<br />

its previously stored value, as you can see in Figure 23.2.<br />

Figure 23.2<br />

The value of the session variable is passed along via the session<br />

ID to page2.php.<br />

After you have used the variable, you unset it.The session still exists, but the variable<br />

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

Finally, you pass along to page3.php, the final script in the example.The code for this<br />

script is shown in Listing 23.3.<br />

Listing 23.3<br />

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

Saved successfully!

Ooh no, something went wrong!