<?

logger("

###################################################################################
###################################################################################
## START:  [/shared/session_clear.shared]
###################################################################################

");


/*


$clear_template = "NO";
$clear_session = "NO";
$clear_cookies = "NO"; // clear all
include($template['company']['file_path'] . "shared/session_clear.shared");


*/





/// legacy fix:
if($session_restart) { 
	$restart_session = $session_restart;  
	unset($session_restart); 
}

if($session_clear_restart) { 
	$restart_session = $session_clear_restart;  
	unset($session_clear_restart); 
}


### SET TMP VARS
if(isset($_SESSION['session']['access_status'])) {
	$tmp_session_access_status = $_SESSION['session']['access_status'];
} else if($access_status) {
	$tmp_session_access_status = $access_status;
}


logger3("0. session['access_status']",$_SESSION['session']['access_status']);
logger3("0. tmp_session_access_status",$tmp_session_access_status);

if(isset($_SESSION['session']['secret_password'])) $tmp_session_secret_password = $_SESSION['session']['secret_password'];
logger3("0. session['secret_password']",$_SESSION['session']['secret_password']);
logger3("0.tmp_session_secret_password",$tmp_session_secret_password);




### UNSET VARS
# if( strtoupper($clear_account) != "NO") $_SESSION['account'] = $account = NULL;
# 
# if( strtoupper($clear_action) != "NO") $_SESSION['action'] = $action = NULL;
# 
# if( strtoupper($clear_admin) != "NO") $_SESSION['admin'] = $admin = NULL;
# 
# if( strtoupper($clear_authorization) != "NO") $_SESSION['authorization'] = $authorization = NULL;
# 
# if( strtoupper($clear_banned) != "NO") $_SESSION['banned'] = $banned = NULL;
# 
# if( strtoupper($clear_details) != "NO") $_SESSION['details'] = $details = NULL;
# 
# if( strtoupper($clear_display) != "NO") $_SESSION['display'] = $display = NULL;
# 
# if( strtoupper($clear_edit) != "NO") $_SESSION['edit'] = $edit = NULL;
# 
# if( strtoupper($clear_error) != "NO") $_SESSION['error'] = $error = NULL;
# 
# if( strtoupper($clear_gateway) != "NO") $_SESSION['gateway'] = $gateway = NULL;
# 
# if( strtoupper($clear_http) != "NO") $_SESSION['http'] = $http = NULL;
# 
# if( strtoupper($clear_member) != "NO") $_SESSION['member'] = $member = NULL;
# 
# if( strtoupper($clear_notification) != "NO") $_SESSION['notification'] = $notification = NULL;
# 
# if( strtoupper($clear_payme) != "NO") $_SESSION['payme'] = $payme = NULL;
# 
# if( strtoupper($clear_session) != "NO") $_SESSION['session'] = $session = NULL;
# 
# if( strtoupper($clear_SYSMSG) != "NO") $_SESSION['SYSMSG'] = $SYSMSG = NULL;
# 
# if( strtoupper($clear_template) != "NO") $_SESSION['template'] = $template = NULL;
# 
# if( strtoupper($clear_transaction) != "NO") $_SESSION['transaction'] = $transaction = NULL;
# 
# if( strtoupper($clear_transactions) != "NO") $_SESSION['transactions'] = $transactions = NULL;
# 
# if( strtoupper($clear_shopping) != "NO") $_SESSION['shopping'] = $shopping = NULL;


### UNSET VARS (NEW)
unset($temporary_session);
$temporary_session = array();

if (strtoupper($clear_account) == "NO") $temporary_session['account'] = $_SESSION['account']; else unset($account);

if( strtoupper($clear_action) == "NO") $temporary_session['action'] = $_SESSION['action']; else unset($action);

if( strtoupper($clear_admin) == "NO") $temporary_session['admin'] = $_SESSION['admin']; else unset($admin);

if( strtoupper($clear_authorization) == "NO") $temporary_session['authorization'] = $_SESSION['authorization']; else unset($authorization);

if( strtoupper($clear_banned) == "NO") $temporary_session['banned'] = $_SESSION['banned']; else unset($banned);

if( strtoupper($clear_details) == "NO") $temporary_session['details'] = $_SESSION['details']; else unset($details);

if( strtoupper($clear_display) == "NO") $temporary_session['display'] = $_SESSION['display']; else unset($display);

if( strtoupper($clear_edit) == "NO") $temporary_session['edit'] = $_SESSION['edit']; else unset($edit);

if( strtoupper($clear_error) == "NO") $temporary_session['error'] = $_SESSION['error']; else unset($error);

if( strtoupper($clear_gateway) == "NO") $temporary_session['gateway'] = $_SESSION['gateway']; else unset($gateway);

if( strtoupper($clear_http) == "NO") $temporary_session['http'] = $_SESSION['http']; else unset($http);

if( strtoupper($clear_member) == "NO") $temporary_session['member'] = $_SESSION['member']; else unset($member);

if( strtoupper($clear_mode) == "NO") $temporary_session['mode'] = $_SESSION['mode']; else unset($mode);

if( strtoupper($clear_notification) == "NO") $temporary_session['notification'] = $_SESSION['notification']; else unset($notification);

if( strtoupper($clear_payme) == "NO") $temporary_session['payme'] = $_SESSION['payme']; else unset($payme);

if( strtoupper($clear_route) == "NO") $temporary_session['route'] = $_SESSION['route']; else unset($route);

if( strtoupper($clear_session) == "NO") $temporary_session['session'] = $_SESSION['session']; else unset($session);

if( strtoupper($clear_SYSMSG) == "NO") $temporary_session['SYSMSG'] = $_SESSION['SYSMSG']; else unset($SYSMSG);

if( strtoupper($clear_template) == "NO") $temporary_session['template'] = $_SESSION['template']; else unset($template);

if( strtoupper($clear_transaction) == "NO") $temporary_session['transaction'] = $_SESSION['transaction']; else unset($transaction);

if( strtoupper($clear_transactions) == "NO") $temporary_session['transactions'] = $_SESSION['transactions']; else unset($transactions);

if( strtoupper($clear_shopping) == "NO") $temporary_session['shopping'] = $_SESSION['shopping']; else unset($shopping);


$_SESSION = NULL;
logger3("UNSET: _SESSION",$_SESSION);
if(isset($temporary_session)) {
	
	$_SESSION = $temporary_session;
	//test("0 _SESSION",$_SESSION);
}

if($clear_cookies != "NO") {
	
	//test("master_config_domain",$master_config_domain);
	//setcookie("COOKIE_SESSION", "", 1); // DELETES COOKIE
	//if(!isset($temporary_session)) setcookie("COOKIE_SESSION", "", 1, "/", "." . $master_config_domain, 0);
	if(!isset($temporary_session)) setcookie("BSESSION", "", 1, "/", "." . $master_config_domain, 0);
	setcookie("test_cookie", "", 1, "/", "." . $master_config_domain, 0);
	setcookie("cookie_banking_country", "", 1, "/", "." . $master_config_domain, 0);
	setcookie("cookie_banking_country_text", "", 1, "/", "." . $master_config_domain, 0);
	//test("clear_cookies",$clear_cookies);
	//setcookie("cookie_banking_country", "", 1);
	//setcookie("cookie_banking_country_text", "", 1);
	//setcookie("cookie_access_status", "", 1);
	if(!isset($tmp_session_access_status)) setcookie("cookie_access_status", "", 1, "/", "." . $master_config_domain, 0);
	
	//test("_COOKIE",$_COOKIE);
}

//test("0 _SESSION",$_SESSION);


### RE-ESTBLISH SESSION STATUS:
logger3("restart_session",$restart_session);
if(strtoupper($restart_session) != "NO") {
	
	/// start globals
	include($master_config_root_path . "/shared/session.shared");
	
	/// set saved vars
	if( (!$_SESSION['session']['access_status']) && ($tmp_session_access_status) ) {
	    $_SESSION['session']['access_status'] = $tmp_session_access_status;
	}
	logger3("session['access_status']",$_SESSION['session']['access_status']);
	
	
	if( (!$_SESSION['session']['secret_password']) && ($tmp_session_secret_password) ) {
	    $_SESSION['session']['secret_password'] = $tmp_session_secret_password;
	}
	logger3("session['secret_password']",$_SESSION['session']['secret_password']);
	
	//	/// grant special access
	//	if($testing) {
	//	    echo "TESTING";
	//	    $_SESSION['session']['access_status'] = "Granted";
	//	    
	//	}
}

//test("2 _SESSION",$_SESSION);


//test("session['secret_password']",$_SESSION['session']['secret_password']);

### clear action vars:

unset($clear_account);

unset($clear_action);

unset($clear_admin);

unset($clear_authorization);

unset($clear_banned);

unset($clear_details);

unset($clear_display);

unset($clear_edit);

unset($clear_error);

unset($clear_gateway);

unset($clear_http);

unset($clear_member);

unset($clear_notification);

unset($clear_payme);

unset($clear_session);

unset($clear_SYSMSG);

unset($clear_template);

unset($clear_transaction);

unset($clear_transactions);

unset($clear_shopping);







logger("


###################################################################################
## END:  [/shared/session_clear.shared]
###################################################################################
###################################################################################


");

?>
