PHP Session Expires When Browser is closed

I want to know how can I keep my users logged in forever using PHP session? I also want to know how can I control the length of each session, like an user will be logged in for 10 days.
Please explain clearly with codes and directions.

Best regards
Thanks in advance
Ashikur Rahman Shad

I mean. It is not really expires after browser closed. Sessions will be hoarded in PHPSESSID cookie. By default it will expire after a day except same session exists in another device or cookies be cleared.

1 Like

You can implement some kind of “Remember Me” system. A common way to store this is to put a remember me token into a cookie in the browser of the visitor and store it in the database. When a user accesses your site and they have a valid remember me token, you can log them in again.

I’m not going to spoon feed you code for that though. There are tons of examples online you can check for yourself.

1 Like

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.