Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How does php deal with the problem of setcookie failure

2025-03-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

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.

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.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report