/home/wpollock1/public_html/PHP/Session1.php

 1: <?php session_start();  # This must be first byte in file!
 2: ?>
 3: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
 4:          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 5: <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 6: <head>
 7: <meta http-equiv="Content-Type"
 8:       content="application/xhtml+xml; charset=utf-8" />
 9: <meta http-equiv="Vary" content="Content-language" />
10: 
11: <title> PHP Session test #1 </title>
12: 
13: <!-- Although better to use external style sheet,
14:      for Q&D developement this is easier
15: -->
16: <style type="text/css" id="internalStyle">
17: <![CDATA[
18: body        { background-color: cyan; }
19: h1          { text-align: center; }
20: ]]>
21: </style>
22: 
23: <?php if ( isset($_SESSION['count']) )
24:       {  ++$_SESSION['count'];
25:       } else {
26:          $_SESSION['count'] = 1;
27:       }
28: ?>
29: 
30: </head>
31: 
32: <body>
33: <div>
34: <h1> Session test #1 </h1>
35: 
36: <p>
37: On each reload of this page the <em>count</em> should increase by one.
38: </p>
39: 
40: <p>
41: The number of times you have loaded this page during the current
42: session is
43: 
44: <?php print $_SESSION['count'] ?>.
45: 
46: </p>
47: </div>
48: </body>
49: </html>