Skip to content
Advertisement

GAE gcloud dev_appserver.py PHP: Failed to read session data: user (path: Memcache)

I run a local Google Cloud App Engine emulator for my PHP (runtime: php55) app. It works, except for PHP sessions. I get the following message:

Warning: session_start(): Failed to read session data: user (path: Memcache)

I start the app with the following command

dev_appserver.py --php_executable_path=/usr/bin/php-cgi ./default

So I run using php-cgi. Before this I tried to run with regular php but then I got a WSOD. In a Google Group it was a suggested to use php-cgi which solved that problem for me. But now I still have this problem, that seems to be related to Memcache.

This is on Linux Mint (Ubuntu), and this problem didn’t occur on a Windows Machine where I have the same app running in the emulator.

When I install php-memcache, I cannot start the app anymore. When running the above command with php-memcache installed, I get this error:

PHPEnvironmentError: The PHP runtime cannot be run with the 
"Memcache" PECL extension installed

How do I solve this?

Advertisement

Answer

First of all, while struggling with the same problems as you, I found out here that:

dev_appserver.py is not supported with the PHP 7.2 runtime. To test your application and run it locally, you must download and install PHP 7.2 and set up a web server.

That being said, with php-cgi & java it seems to be running, with some differences, memcache extension indeed must be disabled in php.ini, but the runtime register the Memcached class so this should work in both dev & App Engine Env:

extension_loaded('memcached') || class_exists('Memcached')

Back to your question, I solved the session error by doing this in dev mode:

ini_set('session.save_handler', 'files');
ini_set('session.save_path', null);
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement