Cookie Value not available, why?
- by Camran
I have tested this on my development computer, but now I have uploaded everything to the production server and I cant read out the value of the cookie.
I think the problem lies in the Serialization and Unserialization.
if (isset($_COOKIE['watched_ads'])){
$expir = time()+1728000; //20 days
$ad_arr = unserialize($_COOKIE['watched_ads']); // HERE IS THE PROBLEM
$arr_elem = count($ad_arr);
if (in_array($ad_id, $ad_arr) == FALSE){
if ($arr_elem>10){
array_shift($ad_arr);
}
$ad_arr[]=$ad_id;
setcookie('watched_ads', serialize($ad_arr), $expir, '/');
}
}
When I echo this: count($ad_arr) I receive the expected nr, 1 in this case, so there is a value there. But when I echo the value: echo $ad_arr[0]; I get nothing. Completely blank. No text at all.
Anybody have a clue?
if you need more info about something let me know...