<?php
	if(!isset($_SESSION))session_start();
	if(isset($_SESSION['requested_resolution']))$userRes="?kennung=".$_SESSION['requested_resolution'];
	else $userRes="";
	if(isset($_SESSION['selectedMobilPrinterId'])) unset($_SESSION['selectedMobilPrinterId']); 
	
	require_once("config/connect.php");	
	$updQl=mysql_query("UPDATE benutzer_aktiv SET logoff_time = NOW(), session_id = ''  WHERE session_id = '".session_id()."' ");
	if(!$updQl) file_put_contents('kpcheckit.txt', "\n".basename( __FILE__)." ". __LINE__ ." ".date('Ymd Hi')."benutzer aktiv DB: ".mysql_error()." \n", FILE_APPEND);
	
	if(isset($_SESSION)){
		session_destroy();
	#	file_put_contents('kpcheckit.txt', "\n".basename( __FILE__)." ". __LINE__ ." ".date('Ymd Hi')."\nuser ses: ".$_SESSION['userId']." \n", FILE_APPEND);
	}
	
    session_unset();
    session_write_close();
	setcookie(session_name(),'',0,'/');
    session_regenerate_id(true);
	
	header('Location: http://' . $_SERVER['HTTP_HOST'] . rtrim(dirname($_SERVER['SCRIPT_NAME']), '/') . '/index.php'.$userRes);


	

?>