Have you ever wondered why your session are not properly working as expected? Well session depends on various server configurations. On this post I will show you better way to handle sessions in your php apps.
garbage collection max life time: This is to set the no of seconds you want your session to be live on your app. Can be around 1 -2 hrs to whole day depending upon you apps. default is 1400 secs which might now be what you want. These code goes to your bootstrap file or header file where your php app uses as setting environment for your app.
ini_set('session.gc_maxlifetime', 'replace this with no of seconds you want your session to be live');
If you have changed the above value then you will need to set a separate session directory for your app. which can be in your home folder.
So this will make sure it is not overridden by other apps setting.
ini_set('session.save_path', 'path to the session writable directory');
After you set up this two settings in your apps. You will be better session handling in your php app. Make sure the session save path is writable. or you can also use saving session data to database approach as i have mentioned before here.