-
- //Save
- $arr = array(1,2,3);
- $arr_str = serialize($arr);
- setcookie("a",$arr_str);
-
- //Take out
- $ arr_str = $_COOKIE['a'];
- $arr = unserialize($arr_str);
Copy code
Method 2: Set a multi-key value cookie, please note that the key value must be given
-
- $arr = array(1,2,3);
- setcookie("a[0]", $arr[0]);
- setcookie("a[1]", $arr[1] );
- setcookie("a[2]", $arr[2]);
Copy code
Note: The above method is copied from elsewhere. I tried the first method and it was successful. It is also more convenient. I have not tried the second method, so please test it more.
|