Home  >  Article  >  Backend Development  >  What should I do if the php cookie cannot be written?

What should I do if the php cookie cannot be written?

藏色散人
藏色散人Original
2020-07-30 09:44:462817browse

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.

What should I do if the php cookie cannot be written?

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[&#39;cookie&#39;])) {
foreach ($_COOKIE[&#39;cookie&#39;] 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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn