<?php
ini_set('display_errors', 1);
ini_set("log_errors", 1);
include "../settings.php";
include "../include/init.php";
include "../include/functions.php";

$cdata = parse_url($setting['url']);

$ncookie = array();
$ntoken = array();
$ncookie['index'] = 0;

$c = 0;
foreach ($cookie as $key => $elem){
	if(!isset($elem['acct'])){
		continue;
	}
	if ($key == $cookie['index']){
		continue;
	}
	$ncookie[$c] = $elem;
	$c++;
}
setrawcookie("user_settings",base64_encode(json_encode($ncookie)),time()+60*60*24*30,'/');

$c = 0;
$tokens = json_decode(base64_decode($_COOKIE['token']),true);
for ($i=0;$i<=(count($tokens)-1);$i++){
	if ($i == $cookie['index']){
		continue;
	}
	$ntoken[$c] = $tokens[$i];
	$c++;
}
setcookie('token', base64_encode(json_encode($ntoken)), time() + 60 * 60 * 24 * 30, $cdata['path'], $cdata['host'], false, true);


header('Location: '.$setting['url']);