<?php
session_start();
$checkID = $_SESSION['company'];
if($checkID == ""){			
	$checkID = $_SESSION['admin'];
}
else{};
if($checkID == ""){
	$checkID = $_SESSION['agent'];
}
else{};

include("connect.php");
$ip=$_SERVER["REMOTE_ADDR"];
$nowdate = time(); // taking now logged in time
$nowdate2 = $nowdate + (20 * 60);
mysql_query("update logincontrol set ipaddress='$ip',starttime='$nowdate',endtime='$nowdate2',status='0' where id='$checkID '");	

include("closeconnection.php");



if(isset($_SESSION['company'])){
	unset($_SESSION['company']);	
}
elseif(isset($_SESSION['admin'])){
	unset($_SESSION['admin']);	
}
elseif(isset($_SESSION['agent'])){
	unset($_SESSION['agent']);	
}
session_destroy();
session_unset();	
echo"<script language=javascript>window.location='http://localhost/smart/login.php'</script>";	

?>
