Making PHP Sessions last longer

Hello! I am building a project in PHP that involves user authentication. I use PHP sessions to remember that they are logged in. I have a rule in my .htaccess file that allows PHP sessions to virtually last forever, however, when the browser is closed, the sessions are lost. Is there any way to stop this?

Looks like you need to use COOKIES to preserve the login/session ID or something. This answer came up on Google :slight_smile:

write a custom script that moves the cookies to localstorage and back and forth. Just make sure to destroy localstorage on logout too

They better add this in PHP 8 :laughing:

1 Like