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.

    打赏 评论

相关推荐 更多相似问题