Hello guys,
Why these setting a cookie below works only under my computer.
When I use different computer it doesn’t work.
//Set or Extend Cookie logoutid.
function lidgen() {
//If cookie is not set
//set cookie logoutid
if(!isset($_COOKIE['logoutid'])) {
$expire = 60 * 60 * 24 * 180 + time(); //Expire in 6 months.
//$expire_unset = time() - 86400;
//$logoutid = Modules::run('tasks/cidgen'); //Get unique logoutid.
$logoutid = $this->cidgen();
//Delete existing duplicate logoutid in completion table.
$this->completion_mdl->delete_logoutid($logoutid);
setcookie("logoutid", $logoutid, $expire);
return $logoutid;
}
//If cookie is set
//Extend cookie expiration
if(isset($_COOKIE['logoutid'])) {
$expire = 60 * 60 * 24 * 180 + time(); //Expire in 6 months.
//$expire_unset = time() - 86400;
$logoutid = $_COOKIE['logoutid'];
setcookie("logoutid", $logoutid, $expire);
return $logoutid;
}
}
//Generate random unique cookie logout_id.
function cidgen() {
//generate unique logout id.
//Find match from completion table.
//If match found re-generate the logout id again.
//If match not found store to cookie.
$logout_id_random = md5(uniqid(rand(), true));
//echo $logout_id_random;
//Check if $logout_id_random already exist in the database.
$logout_id_found = $this->completion_mdl->match_logout_id($logout_id_random);
if($logout_id_found) {
$this->cidgen(); //Regenerate logout id again, if found duplicate in the database.
} else {
//store to cookie
$logout_id_random;
}
}
Thanks in advance, whoever will explain to me the reason.