Home > Article > Backend Development > What should I do if the php cookie cannot be written?
php cookie cannot be written because the cookie is written incorrectly. The solution is: first set the cookie through the "setcookie" function; then use isset and other functions to realize the function that is displayed after refreshing the page; finally execute the corresponding file That’s it.
Recommended: "PHP Video Tutorial"
Code examples such as:
<?php // 设定cookie setcookie("cookie[three]", "cookiethree"); setcookie("cookie[two]", "cookietwo"); setcookie("cookie[one]", "cookieone"); // 刷新页面后,显示出来 if (isset($_COOKIE['cookie'])) { foreach ($_COOKIE['cookie'] as $name => $value) { echo "$name : $value \n"; } } ?>
Above example Will output:
three : cookiethree two : cookietwo one : cookieone
The above is the detailed content of What should I do if the php cookie cannot be written?. For more information, please follow other related articles on the PHP Chinese website!