Speichern, array in cookie

Ich bin die Umwandlung array in cookie von php serialize-Funktion

$PromoteProductArray = array("PromoteuserId"=>$PromoteuserId,
"PromoteProductId"=>$PromoteProductId,
"PromoteBrandId"=>$PromoteBrandId);

$Promotedcart[] = $PromoteProductArray;

setcookie("Promotedcart", serialize($Promotedcart), time()+604800,'/');

Und wenn der cookie wird erstellt, dann bin ich mit der php-Funktion unserialize.

print_r(unserialize($_COOKIE['Promotedcart'])); 

funktioniert es nicht.

Wenn ich print_R($_COOKIE) dann ist es mir das Wert.

Test-Daten können sehr hilfreich sein, können Sie post-Probe
Siehe diese StackOverflow-Frage für eine bessere Antwort.
Bitte verwenden Sie nicht unserialize auf user-Daten übermittelt haben. Dies ist leicht ausnutzbar mit object-injection mit PHP die __wakeup und __destruct Methoden. Sie können json_encode/json_decode statt serialize/unserialize. owasp.org/index.php/PHP_Object_Injection

InformationsquelleAutor Amit | 2011-09-14

Schreibe einen Kommentar