you can use ini_alter() to change the value of how long sessions last in you php.ini file. check the value of session.cookie_lifetime. If it is 0 it means the session will stay until the browser is closed but you can also change it to a high value. I wouldn't recommend having sessions last forever due to security as well as server performance because it will take up lots of space having the sessions never go away. If you need people to stay logged in I would suggest using only cookies to log them in.
So try this code:
ini_alter("session.cookie_lifetime",86400);
where 86400 is how long you want the session to last in seconds.