In effetti la strada più semplice penso sia quella che sto usando ora, anche se continua a non funzionare. Ho modificato il codice così, giusto per capire dove sbaglio:
codice:
function saveCookie_DS (cb) { //alert(cb.value + " - " + cb.checked);
if (cb.checked == true) {
document.cookie = cb.value + "=OK";
} else {
document.cookie = cb.value + "=KO";
}
}
L'alert in javascript mi restituisce valori corretti
codice:
foreach ($array_distretti_sigla as $key => $value) { if (isset($_COOKIE[$key]) == "OK") {
print("_COOKIE ".$key." - ".$_COOKIE[$key]." -</br>");
//.......
$cb_DS_HTML .= "<input type='checkbox' name='".$key."' id='".$key."' value='".$key."' checked onChange='saveCookie_DS(this)' /><label>".$array_distretti_sigla[$key]." </label>";
array_push($array_DS_show, $key);
} else {
print("_COOKIE non trovato per ".$key."</br>");
//.......
$cb_DS_HTML .= "<input type='checkbox' name='".$key."' id='".$key."' value='".$key."' onChange='saveCookie_DS(this)' /><label>".$array_distretti_sigla[$key]." </label>";
}
}
Magari il problema è in php, perché di questi cookie
codice:
if (isset($_COOKIE[$key]) == "OK") {
non ne arriva nessuno e di conseguenza i vari checkbox (quelli spuntati in precedenza) non vengono rispuntati, come neppure viene riempito il nuovo array in php.