<?php session_start(); 
include 'dbcon.php';
include ('functions.php');

$id=$_SESSION['uid'];

if(isset($_SESSION['chatmod']) && $_SESSION['chatmod']=='on'){
$timenow = date('Y-m-d H:i:s');
mysqli_query($con, "UPDATE tbl_chat SET online='0', last_acive = '$timenow' WHERE id='$id'");    
}

if(!isset($_SESSION['uid'])){
// Unset all of the session variables
$_SESSION = array();
	
// Destroy the session.
session_destroy();
	
// Redirect to login page
header("location: ../index.php");
exit;	
}

write_activity($id,'LOG','Login Record','Successfully logout','লগইন রেকর্ড','বাহির সফল হয়েছে।');
// Unset all of the session variables
$_SESSION = array();
 
// Destroy the session.
session_destroy();

foreach ($_SESSION as $key => $value) {
unset($_SESSION[$key]);
} 
// Redirect to login page
header("location: ../index.php");
exit;
?>