In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly introduces how to solve the problem of setcookie failure in php. It is very detailed and has a certain reference value. Interested friends must read it!
The solution to php setcookie failure: 1, the browser opens cookie;2 and deletes any HTTP header output before setcookie (); 3, use php's setcookie () to create cookie.
This article operating environment: Windows7 system, PHP7.1 version, DELL G3 computer
The php setcookie function is invalid?
Recently, when I was writing the php background for a website, I found that the function setcookie could not set cookie normally. Through var_dump (), I found that the return value of the function was false. Obviously, the setting was not successful. Google found that there may be some reasons for setcookie failure:
Cookie is disabled in the browser. No need to check. I'm sure I didn't ban it.
Use php's setcookie () to create a cookie, just like session_start () with session turned on in php, there can be no HTTP header output before setcookie (). I went to check the code and found the following code
Var_dump ($qOpenId)
Setcookie ('qOpenId',$openid,time () + 30 * 24 * 3600)
Decisively comment on the line var_dump ($OpenId), test, successful.
Personally, I think that setcookie should directly set the contents of http header, so there can't be any header output in front of it, var_dump,echo or anything else.
These are all the contents of this article entitled "how to solve the problem of setcookie failure 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.