Cookie未存储在用户浏览器php 7,Google App Engine [GAE]中 [英] Cookie not storing on users browser, php 7, Google App Engine [GAE]
问题描述
我有一个奇怪的问题。对不起,我还没有在网上看到任何解决方案。我似乎无法在PHP的Google App Engine上的用户浏览器上设置和存储cookie。
I have a strange issue. Pardon me, I have not seen any solution to it online. I seem not to be able to set and store cookie on users browsers on Google App Engine, PHP.
在localhost上,它运行良好,在Godaddy上,它也运行良好,但是迁移到Google后云,它不再起作用,我在本地主机上使用PHP 5,而GAE的运行时[PHP版本是什么]是PHP 7。
On localhost it works perfectly, on Godaddy it also works perfectly, but after migrating to Google cloud, it doesn't work again, I use PHP 5 on localhost, while the runtime[What the PHP version is] for GAE is PHP 7.
这是我用来创建的内容用户浏览器上的Cookie
This is what i use to create cookie on users browsers
$cookie_name = "bla_bla_bla";
setcookie('browsing_tracker', $cookie_name, time() + (3000 * 24 * 60 * 60));
这是我用来删除Cookie的内容。
This is what I use to remove the cookie.
setcookie("browsing_tracker", "", time() - 3600);
但是它不起作用,用户浏览器中没有存储cookie。
But it does not work, no cookie is stored on the users browser.
我进行了编辑,添加了一个PHP.INI文件,并以此方式存储了cookie,但仍然无法解决。
I made an EDIT, added a PHP.INI file, also stored the cookie as this, it still did not work out.
新的cookie设置样式
New cookie setting style
$cookie_name = "bla_bla_bla";
setcookie('browsing_tracker', $cookie_name, time() + (3000 * 24 * 60 * 60), "/");
php.ini文件
session.use_cookies = 1
session.name = PHPSESSID
session.cookie_path = /
推荐答案
应该这样做:
$cookie_name = "bla_bla_bla";
setcookie('shopping_tracker', $cookie_name, time() + (3000 * 24 * 60 * 60), "/");
未设置路径
大多会阻止cookie的创建。
Not setting the path
mostly prevents the cookie from being created.
这篇关于Cookie未存储在用户浏览器php 7,Google App Engine [GAE]中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!