我知道在 php 中存储数据的方法。但是当我在 PHP 中存储一个长数组时,这种方法不起作用。该数组有大约 3000 个值(82382 个字符)。
我正在这样做:
$encoded_db_data = base64_encode(serialize($query_result));
setcookie("db_select_result", '$encoded_db_data');
但db_select_result正在打印空白(无值)。我怎么解决这个问题?
A user agent MAY ignore a received cookie in its entirety. For example, the user agent might wish to block receiving cookies from "third-party" responses or the user agent might not wish to store cookies that exceed some size.
From: http://www.faqs.org/rfcs/rfc6265.html
Consider the next options:
1.Split the array's data and put it in more than one cookie.
2.Use sessions
(Unlike cookies they have "short-life") [http://www.php.net/manual/en/session.examples.basic.php]
3.Store that data in a Database
with a "unique key" , then set a cookie with that
unique key so you'll be able to identify which data to pull from the database.
4.Use less data from your array and try to put it in a cookie.