RyanSF07 Posted April 1, 2007 Share Posted April 1, 2007 Hi all, Is there a way for me to define how long a user remains logged in to the site? -- 10 hours for example? Thanks, Ryan Link to comment https://forums.phpfreaks.com/topic/45187-how-do-i-adjust-length-of-log-in-time/ Share on other sites More sharing options...
DeathStar Posted April 1, 2007 Share Posted April 1, 2007 Cookies! Link to comment https://forums.phpfreaks.com/topic/45187-how-do-i-adjust-length-of-log-in-time/#findComment-219366 Share on other sites More sharing options...
maxic0 Posted April 1, 2007 Share Posted April 1, 2007 Can you post a bit of code so we can see please? Link to comment https://forums.phpfreaks.com/topic/45187-how-do-i-adjust-length-of-log-in-time/#findComment-219370 Share on other sites More sharing options...
DeathStar Posted April 1, 2007 Share Posted April 1, 2007 lol.. just set a coockie on login then set it to expire in 10hours.. and check on every page to see if the cookie exists, if not direct to login page Link to comment https://forums.phpfreaks.com/topic/45187-how-do-i-adjust-length-of-log-in-time/#findComment-219373 Share on other sites More sharing options...
RyanSF07 Posted April 1, 2007 Author Share Posted April 1, 2007 Only recently has this begun to happen... I'm randomly logged off from the site for no apparent reason. It happens so frequently though that something must be causing it, but I haven't found out what, yet. When a user logs in, I start a session - and begin each php page with session_start(). I don't know why the user_id variable is sometimes lost, resulting in "You must log in" message. Any ideas what to look for? an absent session_start() maybe? Thanks, Ryan //start session session_start(); header("Cache-control: private"); //IE 6 Fix //Register session key with the value $_SESSION[id] = $row[id]; $_SESSION[name] = "$row[user_name]"; //output success message $content .= "<h1>Welcome <b>$_SESSION[name]!</b></h1> <p>You are logged in.</p>"; Link to comment https://forums.phpfreaks.com/topic/45187-how-do-i-adjust-length-of-log-in-time/#findComment-219412 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.