英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论