<?php
if(empty($_SESSION['username']) || $_SESSION['username'] == ''){
    header("Location: index.php");
    exit();
} else if ($_SESSION['peran'] != 'admin') {
    header("Location: homepage.php");
    exit();
}

// set timeout period in seconds
$inactive = 900;
// check to see if $_SESSION['timeout'] is set
if(isset($_SESSION['timeout']) ) {
	$session_life = time() - $_SESSION['timeout'];
	if($session_life > $inactive)
        { session_destroy(); header("Location: logout.php"); }
}
$_SESSION['timeout'] = time();

?>