In the next example, we are going to see how we can use the built-in mechanisms in PHP for handling sessions.
1. Open up your text editor and put the following code in a new file:
<?php session_start(); //Generate a random number $random_number = rand(); //Put the number into session $_SESSION['random_number'] = $random_number; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <link rel="stylesheet" href="style.css" /> <title>Understanding PHP sessions...Page 1</title> </head> <body> <div id="contentarea"> <div id="innercontentarea"> <h2>Understanding PHP sessions...Page 1</h2> <p>Random number generated <span style="font-weight...