I'm writing a class to control how cookies are handled for a custom CMS I'm working on and I was curious as to the best approach to updating a cookie once it's been created. Below I've pasted a function from my class that I'm using to currently update cookies but it doesn't seem to be working properly. The issue I'm having is that the cookie does not seem to change even though this function returns "true".
function updateCookie($data){
$cookieArray = $this->getCookie();
array_push($cookieArray,$data);
//print_r($cookieArray);
$json_string = json_encode($cookieArray,true);
if(setcookie(_COOKIENAME, $this->encodeString($json_string,"S33D"))){
return true;
}
else return false;
}
Suggestions or corrections would be helpful.
Thanks