douliedai4838 2019-03-28 05:47
浏览 67
已采纳

无法在prestashop Context :: getContext() - > cookie中找到cookie值但是它在$ _COOKIE中显示?

I am creating a module in which I use third party Js. That JS create a cookie in browser. At backend I want to read that cookie by the help of prestashop cookie class (Context::getContext()->cookie / $this->context->cookie ) but unable to find that cookie value, If I use php default $_COOKIE it work fine.

Ex: My cookie key is xyz, and value is 123456abc. When I use print_r($_COOKIE) It print [xyz]= "123456abc"

But when I use prestashop Cookie It doesn't print anything.

  • 写回答

1条回答 默认 最新

  • dtslobe4694 2019-03-29 19:11
    关注

    This is because you are most likely writing to a cookie with different name or different domain/sub-domain.

    The PrestaShop admin cookie name is psAdmin whereas the front-end one is ps-s1.

    Using Google Chrome, press F12 and go to: Applications > Cookies > www.yourstore.com

    You should now see all the different cookie names and values, make sure you are writing in the correct one.

    An alternate solution can be to call your PrestaShop controller file directly from JS (using Ajax) to set the cookie value via PHP.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 lammps拉伸应力应变曲线分析
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥15 请问Lammps做复合材料拉伸模拟,应力应变曲线问题
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划
  • ¥15 java 操作 elasticsearch 8.1 实现 索引的重建