<?
session_set_cookie_params(60*60*24);
session_start();
//echo "isset(\$_COOKIE['PHPSESSID']): ", isset($_COOKIE["PHPSESSID"]),"<p>";
//echo "Using \$_GET['PHPSESSID']: ", $_GET['PHPSESSID'], "<br>";
//echo "The session ID number using SID is: ", SID, "<br>";
//echo "The session ID number using session_id() is: ", session_id(), "<br>";
//$array = session_get_cookie_params();
/*echo "Contents of the session cookie: <br>";
foreach ($array as $v)
        echo "$v<br>";
*/

# The following line is used to change the session ID.
# If you provide an true as an argument, the session data will be
# erased. If you don't provide an argument or you provide false, 
# the data won't be erased.
//session_regenerate_id();
//echo "The session ID number using session_id() is: ", session_id(), "<br>";
//echo $_SESSION['user'];
?>
<html>
<body>
<center>
<?
if (!isset($_SESSION['user']) || empty($_SESSION['user']))
{
	echo "<p align='center'>You are not logged in.</p>";
	echo "<a href='session1.php'>Log in</a><BR>";
}
else
{
	$username = $_SESSION['user'];
	echo "Your username is: $username<br>";

	if (!isset($_SESSION['counter']))
        	echo "No visits so far.<p>";
	else
	{
		$_SESSION['counter']++;
	        $count = $_SESSION['counter'];
       	 	echo "This computer visited the homepage: $count times.";
	}
	echo "<br><a href='session3.php?", strip_tags(session_id()), "'>log out</a>";
}
?>
</center></body></html>
