I currently use session_start to keep my members logged in to my forum. But sometimes they log out unexpectedly.
I have session_start() on every page and usually they log out randomly when they change between pages on the forum. I suspect I could set a cookie that keeps them logged in but before I make the changes I wonder why this happens?
My code is;
Code:
require_once( './lib.php');
$user_logged = FALSE;
session_start();
if (isset($_SESSION[user])) {
$user_logged = TRUE;
} else {
...
}
This is the basic script I use on each page that checks whether $_SESSION[user] is set and to change the variable $user_logged to TRUE so the member functions in the script activate. I know this is a terrible way of doing things and I intend to rework the forum software on the next update.
But I am curious as to why members randomly log out? Is it because I set a variable and use require_once() before session_start() ???
Any help would be appreciated.
Thanks
catcalls
