I had the same problem for a while, and it was very difficult for me to understand it. My problem was that I had a website that worked for a while, when the sessions worked correctly, and then everything suddenly broke.
Apparently your session_save_path (), for me this is / var / lib / php 5 /, should have 777 chmod permissions. I accidentally changed it, completely breaking the session.
To fix, just do sudo chmod -R 777 /var/lib/php5/ (or whatever your session_save_path ()) is on linux.
EDIT: changing the permission to 777 is not the best solution if you know the user you are running on your server. Run sudo chmod -R 700 /var/lib/php5/ and then sudo chown -R www-data /var/lib/php5/ so that the php user has access to this folder.
source share