无法在某些WordPress主机上读取cookie。

huangapple go评论65阅读模式
英文:

Can't read cookie on some wordpress hosts

问题

我有一个WordPress插件,它使用以下代码来读取cookies:

if (isset($_COOKIE["status"])) {
   return true;
}

当在SiteGround托管的网站上运行时,这段代码可以正常工作。但当我在euroDNS托管的网站上运行时,它永远无法读取到cookie,尽管我可以在浏览器调试选项卡中看到它。

是否有一些WordPress托管提供商禁用了对cookie的读取?

英文:

I have a WordPress plugin that reads cookies using:

if (isset($_COOKIE["status"])) {
   return true;
}

This code works fine when running on a website hosted on SiteGround. When I run on a website hosted on euroDNS it can never read the cookie, even thought I can see it in the browser debug tab.

Do some WordPress hosting providers disable the reading of cookies?

答案1

得分: 0

通过在cookie名称前添加前缀“wordpress_”来解决了这个问题。这似乎是在某些托管环境中允许cookie传递到我的插件的必要步骤。

英文:

Resolved this by adding the prefix wordpress_ to the start of the cookie name. That seems to be required to allow the cookies to be passed all the way to my plugin on some hosting environments.

huangapple
  • 本文由 发表于 2023年7月24日 16:52:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/76752820.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定