简体   繁体   English

使用php cURL在子域上设置cookie

[英]Using php cURL to set a cookie on a subdomain

I am trying to use curl to set a cookie on a subdomain. 我正在尝试使用curl在子域上设置cookie。 Everything is working except for the cookie being set. 除了设置了cookie外,其他所有东西都在工作。

Am I wrong to think the following sets a cookie across all subdomains? 我认为以下内容会在所有子域中设置Cookie是我错了吗?

setcookie('cookiename','value', time()+3600,"/",".domain.com");

Am I wrong to think the following sets a cookie across all subdomains? 我认为以下内容会在所有子域中设置Cookie是我错了吗?

Yes, you are wrong. 是的,你错了。 setcookie() is not related to curl in any way. setcookie()与卷曲没有任何关系。 So this won't work. 所以这行不通。

You might be looking for CURLOPT_COOKIE and similar curl options, see Sending cookie in cURL request . 您可能正在寻找CURLOPT_COOKIE和类似的curl选项,请参阅在cURL request中发送cookie

Further on, you find the actual specification RFC 6265 more specifically 5.2.3. 进一步,您会发现实际的规范RFC 6265,尤其是5.2.3。 The Domain Attribute . 域属性

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM