skip to Main Content

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.

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.

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));

This is what I use to remove the cookie.

 setcookie("browsing_tracker", "", time() - 3600);

But it does not work, no cookie is stored on the users browser.

I made an EDIT, added a PHP.INI file, also stored the cookie as this, it still did not work out.

New cookie setting style

$cookie_name = "bla_bla_bla";
setcookie('browsing_tracker', $cookie_name, time() + (3000 * 24 * 60 * 60), "/");

php.ini file

session.use_cookies = 1
session.name = PHPSESSID
session.cookie_path = /

2

Answers


  1. This should do it:

     $cookie_name = "bla_bla_bla";
     setcookie('shopping_tracker', $cookie_name, time() + (3000 * 24 * 60 * 60), "/");
    

    Not setting the path mostly prevents the cookie from being created.

    Login or Signup to reply.
  2. This sounds like a bug. Please use a Google Issue Tracker to report this behavior.This forum is meant for programming advice but reporting an issue is the way to go.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search