<?php
    
require ('User_class.php');
    require 
'libs/Smarty.class.php';  
    
session_start();
    
$smarty = new Smarty();    
    
$smarty->assign('skript'$_SERVER['PHP_SELF']);

    if (isset(
$_POST['logout'])){


        
// Unset all of the session variables.
        
$_SESSION = array();
    
//    $_SESSION['bruker'] = new User("null","null");  
    //    print_r ($_SESSION);

        // If it's desired to kill the session, also delete the session cookie.
        // Note: This will destroy the session, and not just the session data!
        
if (isset($_COOKIE[session_name()])) {
            
setcookie(session_name(), ''time()-42000'/');
            }

            
// Finally, destroy the session.
        
session_destroy();
        
$smarty->assign('destroyed'true); 
        
//exit();
    
}

    if (!isset(
$_SESSION['bruker'])){
        
//session_regenerate_id();
        
$_SESSION['bruker'] = new User("kc","Knut Collin");
    }

         if(
$_SESSION['bruker']->verifyUser()){
            
$_SESSION['bruker']->access();
            
$smarty->assign('brukernavn'$_SESSION['bruker']->getFullName());
            
$smarty->assign('hits'$_SESSION['bruker']->getHits());   
            
// print_r ($_SESSION);
        
}
        else {
            
$smarty->assign('hijacked'true);

    }
        
$smarty->display('sessiontest.tpl');   
?>