0

I have got a problem with my php sessions. I have created a debian server on Azure and installed a php/MySQL/apache on it.

The code I use is functional, because it works on my production server but impossible to read $_SESSION variables on this new server.

I can see files well written in /var/lib/php5/sessions, and this directory is readable for the apache user.

In a same page, the $_SESSION variables are available, but not after a redirection on another page.

Is anybody has an idea ? in apache2.conf ? php.ini? network configuration ?

David Makogon
  • 69,407
  • 21
  • 141
  • 189
PHP3959
  • 1
  • 1

1 Answers1

0

As the production PHP runtime, the session is disabled by default, you can check the PHP configurations via phpinfo() function for the setting of session.auto_start. Refer to http://php.net/manual/en/session.configuration.php#ini.session.auto-start for more info.

You can set the session.auto_start to 1 in php.ini to enable the session automatically.

Otherwise, you can add the code session_start(); in the begin of your PHP script to enable session manually.

Gary Liu
  • 13,758
  • 1
  • 17
  • 32
  • Thanks for your answer Gary. Actually, on my production server, session.auto_start is OFF (0) but I use session_start(); in my code. And it's the same on my dev environment. The problem is elsewhere. – PHP3959 Jun 02 '16 at 08:13
  • Could you please check the issues in this answer of http://stackoverflow.com/a/17242347/4989668 – Gary Liu Jun 02 '16 at 08:25