weixin_33743248 2016-03-01 22:19 采纳率: 0%
浏览 59

用ajax设置cookie

I know this topic was discussed several times. But I can't really figure out why my example is not working.

I have tested it locally and it works.

localhost-cookie-storing
As you can see there are some received cookies.

But on the real web site it is not working. The code is exactly the same.
enter image description here
As you can see there are only sent cookies.

JS and PHP sides are very simple. This is for sure not the coding problem.
This is for example server side (Yii2 PHP framework)

$cookie = new Cookie(); $cookie->name = 'agree-terms'; $cookie->value = '1'; $cookie->expire = time() + 2592000; Yii::$app->getResponse()->getCookies()->add($cookie); echo Json::encode(['success' => true]);

May be something wrong with requests or can be the server configuration. It appears on cargo2share.com website while clicking on close button of cookie agreements block on the bottom of the page.

Any hints are appreciated.

EDIT comparing the response headers:

localhost:

enter image description here


and live version

enter image description here

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
    • ¥15 微信会员卡接入微信支付商户号收款
    • ¥15 如何获取烟草零售终端数据
    • ¥15 数学建模招标中位数问题
    • ¥15 phython路径名过长报错 不知道什么问题
    • ¥15 深度学习中模型转换该怎么实现
    • ¥15 HLs设计手写数字识别程序编译通不过
    • ¥15 Stata外部命令安装问题求帮助!
    • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
    • ¥15 TYPCE母转母,插入认方向