In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces the php cookie how to access the array, the article is very detailed, has a certain reference value, interested friends must read it!
Cookie cannot store arrays by default, so the following is incorrect.
The error is as follows:
Warning: setcookie () expects parameter 2 to be string, array given in
But PHP can parse cookie with the same name followed by [] into an array. The method to implement cookie memory array in php is as follows:
Method 1: first serialize the array with serialize, then store it in COOKIE, and read it out with unserialize to get the original array.
Method 2: set the multi-key value cookie, pay attention to the key value must be given
The copy code is as follows:
$arr = array (1pm 2pm 3)
Setcookie ("a [0]", $arr [0])
Setcookie ("a [1]", $arr [1])
Setcookie ("a [2]", $arr [2])
The result: all the elements of the array are stored in.
Array length: 3
Array ([0] = > 1 [1] = > 2 [2] = > 3)
The following words are incorrect:
$arr = array (1pm 2pm 3)
Setcookie ("a []", $arr [0])
Setcookie ("a []", $arr [1])
Setcookie ("a []", $arr [2])
Result: only the last element is saved
Array length: 1
Array ([0] = > 3)
These are all the contents of the article "how to access arrays in cookie in php". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.