Sessions Not Saving-(PHP_7.2 with NGINX)

Ashutosh Singh
2 min readDec 27, 2020

Well, all hate the Errors right?

But what if you don't find the solution for that, I know it literally pissed us
honestly, I’m pissed coz this error as you can see in the heading,

“The session of PHP are not saving”

How can I verify this exact problem, the simplest way is to create a PHP page with session variable created with values okay then we can create a second page to call those variable a check if the values are popping up or not
If You have got the values then WoOW to you !! NO NEED TO READ THIS !!

But If The VALUES are not showing then This is For You !!

You probably know the rules for the session
1 > session_start(); should be at the very beginning of the page
2> cookies are enabled in your browser
3> You have not messed up with the code, I’m pretty much sure that this will not be the reason.

So let's Solve the Error

Create a file with anyname.php then write the following code

<?phpecho session_save_path();;?>

try to open this page in your browser you will get the path to the default session saving folder OR if you have to change it (I mean the session_save path ) then this will verify the location of the folder you have specified

After You know, the exact location of the save folder goto the directory of that folder and try to check the group of that folder by

ls -la 

IF this is what you see then if you have to change it to the Nginx instead of apache coz you are using the Nginx server on the instance or the pc.
Change the group by the following command

chgrp nginx session
chgrp <group_name> <folder/file_name>

And You are done fixing the Error

Just Restart the O.S and the session will start working.

--

--