<?php

//  ini_set('session.use_trans_sid', true);             //in case it is not set in the php.ini file
    session_start();                                    //Obtain handle to session variables
    
    if (! $_SESSION['name'])                            //if there is no name saved in session                          
        header("Location: session_start.php");          //redirect to start session page
?>

<html>
<body bgcolor=lightyellow>
<h1>Session Type</h1>

<?php

    $duration = time() - $_SESSION['start_time'];       //compute session duration
    $visit    = $_SESSION['counter'];                   //number of time visited 

    if (! $_SESSION['start_time']) $duration = 0;

    print "Your session is using "; 

    if (SID)                                    //if SID var was create
        print "<b>URL re-write</b><p>";         //session is using URL re-write
    else                                        //else
        print "<b>cookies</b><p>";              //session is using cookies

    print "\n<table border=2>";
    print "\n<tr><td><b>session id:            <td>" . session_id();
    print "\n<tr><td><b>cookie PHPSESSID:      <td>" . $_COOKIE['PHPSESSID'];
    print "\n<tr><td><b>URL session string:    <td>" . SID;
    print "\n<tr><td><b>You've been active for:<td>" . $duration . " seconds"; 
    print "\n<tr><td><b>You have visited:      <td>" . $visit    . " times";    
    print "\n<tr><td><b>Content of the _SESSION array <td>";
    print_r($_SESSION);    
    print "\n</table><br>";
?>

<br>
<a href=session_use.php>Click</a> to continue session

<br><br>
<form action=session_xit.php>
<input type=submit value="End Session">
</form>

<?php include "../include.php"; ?>              <!-- hyperlink to see the code -->
</body>
</html>