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 Quote Link to comment Share on other sites More sharing options...
DeathStar Posted April 1, 2007 Share Posted April 1, 2007 Cookies! Quote Link to comment 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? Quote Link to comment 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 Quote Link to comment 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>"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.