Here are the code of my login page where the login script checks for the authenticity of the user and then redirects to inbox page using header function.
<
I had the same issue for a while and had a very hard time figuring it out. My problem was that I had the site working for a while with the sessions working right, and then all of the sudden everything broke.
Apparently, your session_save_path(), for me it was /var/lib/php5/, needs to have correct permissions (the user running php, eg www-data needs write access to the directory). I accidentally changed it, breaking sessions completely.
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 the folder.