Arrays in cookies PHP
问题 How is proper way to store an array in a cookie? in PHP Code example: $number_ticket=2; $info[7][5]=1; $info[8][5]=1; 回答1: Serialize data: setcookie('cookie', serialize($info), time()+3600); Then unserialize data: $data = unserialize($_COOKIE['cookie'], ["allowed_classes" => false]); After data, $info and $data will have the same content. 回答2: To store the array values in cookie, first you need to convert them to string, so here is some options. Storing cookies as JSON Storing code setcookie(