<?php
	// start session
	session_start();
	
	// set time for session timeout
	$currentTime = time() + 25200;
	$expired = 3600;
	
	// if session not set go to login page
	if(!isset($_SESSION['user'])){
		header("location:index.php");
	}
	
	// if current time is more than session timeout back to login page
	if($currentTime > $_SESSION['timeout']){
		session_destroy();
		header("location:index.php");
	}
	
	// destroy previous session timeout and create new one
	unset($_SESSION['timeout']);
	$_SESSION['timeout'] = $currentTime + $expired;

		if(isset($_POST['btnSearch']) && $_POST['btnSearch']!='')
		{
			$_SESSION['keyword']=$_POST['keyword'];
header('Location: studentlist.php');exit;
		}
		elseif(isset($_POST['btnExport']) && $_POST['btnExport']!='')
		{
			$_SESSION['keyword']=$_POST['keyword'];
			$export=true;
    	    		            	    		 include('public/searchdata.php');
		}elseif(isset($_POST['btnClear']) && $_POST['btnClear']!='')
		{
			$_SESSION['keyword']='';
			unset($_SESION['keyword']);
			header('Location: studentlist.php');exit;

		}
		else{

			$_SESSION['keyword']='';
			unset($_SESION['keyword']);
header('Location: studentlist.php');exit;
		}
?>