简体   繁体   English

PHP Cookie和浏览器未将Cookie发送到服务器

[英]php cookies and browser not sending cookie to server

So I have a problem where this doesn't work.. the cookie file named "Main" exists in browser cache, but when I try the below code nothing is collected from it. 所以我有一个问题,这是行不通的..名为“ Main”的cookie文件存在于浏览器缓存中,但是当我尝试下面的代码时,没有任何收集。

 if (isset($_COOKIE["Main"])){
 $user_cookie = $_COOKIE["Main"];
 }

Further digging shows I have another cookie for the same domain name that is part of a wikibridge... 进一步的挖掘显示,我有另一个Cookie,用于与Wikibridge相同的域名。

both cookies have the same contents.. a username "John" exactly. 这两个Cookie的内容均相同。.用户名“ John”正好。

when I try 当我尝试

var_dump($_COOKIE); exit;

I get a bunch of array data, collected from the cookies my browser sends back, but it seems my browser firefox is not sending the "Main" cookie backm, its only sending a bunch of other cookies all part of the same domain name. 我从浏览器发送回的cookie中收集了一堆数组数据,但是看来我的浏览器firefox没有发送“ Main” cookie backm,它只发送了所有其他cookie都属于同一域名。

So despite this $_COOKIE["Main"] existing, it never gets sent back to the server for php to get it contents. 因此,尽管这个$ _COOKIE [“ Main”]存在,它永远也不会被发送回服务器供php获取其内容。

HELP 救命

There are a few possible reasons for cookies of same domain not being sent. 无法发送相同域的Cookie可能有一些原因。

First, I would check to see if the cookie is set as a secure cookie which is only sent for https requests. 首先,我将检查cookie是否设置为仅针对https请求发送的安全cookie。

Second, I would check if the cookie has a specific path that it is set to be active for and your request is not part of that path. 其次,我将检查cookie是否具有设置为活动的特定路径,并且您的请求不属于该路径。

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

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