How does php deal with the problem of setcookie failure
This article introduces php how to deal with the problem of setcookie failure, the content is very detailed, interested friends can refer to, I hope it can be helpful to you.
1. Open cookie in the browser.
2. Delete any HTTP header output before setcookie ().
3. Use setcookie () of php to create a cookie.
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, setcookie should directly set the contents of http header, so there can not be any header output, var_dump,echo and so on.
Knowledge point expansion:
Usage
Setcookie (name,value,expire,path,domain,secure)
Parameter description
Name is required. Specifies the name of the cookie.
Value is required. Specifies the value of cookie.
Expire is optional. Specify the period of validity of the cookie.
Path is optional. Specifies the server path for cookie.
Domain is optional. Specifies the domain name of the cookie.
Secure is optional. Specifies whether cookie is transmitted over a secure HTTPS connection.
Setcookie ("webURL", www.yisu.com, time () + 3600x24); this is the question about how to deal with setcookie failure in php. I hope the above content can be helpful to you and learn more knowledge. If you think the article is good, you can share it for more people to see.