Rocu Posted February 24, 2010 Share Posted February 24, 2010 So I made this basic user system where every guest can register, log in, change their details etc. But the problem is that if they stay on one page for too long (i.e reading a long article) and then click somewhere, they have to login again, which is quite annoying. So could anyone tell me, how could I increase the log-in time of a user. I already tried increasing session expire time, but that didn't work. I googled alot but didn't find much there either, only a few tips and advices but those didn't work either. Thanks in advance! Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/ Share on other sites More sharing options...
khr2003 Posted February 24, 2010 Share Posted February 24, 2010 did you use coockies? if so check this php function http://php.net/manual/en/function.setcookie.php, you can incerease the time paramater as much as you like. Otherwise you have to post the code for us to look Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017341 Share on other sites More sharing options...
Deoctor Posted February 24, 2010 Share Posted February 24, 2010 check this article as well http://www.captain.at/howto-php-sessions.php Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017342 Share on other sites More sharing options...
Rocu Posted February 24, 2010 Author Share Posted February 24, 2010 I used sessions. check this article as well http://www.captain.at/howto-php-sessions.php I did, at first it said I have no permissions. Then I removed the part where it made an extra folder for sessions, after that it didn't give an error but it didn't work either. My user logs out already after 10 minutes, shouldn't the default value should be like 24 minutes or something? Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017488 Share on other sites More sharing options...
Rocu Posted February 24, 2010 Author Share Posted February 24, 2010 By the way, I have a phpBB3 forum installed in a different directory on the same server, maybe that's overwriting some session settings or something? I also tried increasing session time via .htaccess but hopeless aswell. Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017622 Share on other sites More sharing options...
Zane Posted February 24, 2010 Share Posted February 24, 2010 session_cache_expire() call that with an argument of how many minutes you want.. BEFORE session_start(); I.E... if you want them to have an hour of login.. then go session_cache_expire(60); Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017633 Share on other sites More sharing options...
Rocu Posted February 24, 2010 Author Share Posted February 24, 2010 session_cache_expire() call that with an argument of how many minutes you want.. BEFORE session_start(); I.E... if you want them to have an hour of login.. then go session_cache_expire(60); Didn't work. I set it up for 60 minutes and then was idle for 50 minutes but still logged out. Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017712 Share on other sites More sharing options...
greatstar00 Posted February 24, 2010 Share Posted February 24, 2010 so, use cookie, client side cookie that is what most website's auto login is using after u closed the browser, and u open it 3 days later, u are still logged in use auto login until they press the log out button Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017731 Share on other sites More sharing options...
ignace Posted February 25, 2010 Share Posted February 25, 2010 No don't use client side cookies to auto-login a user many do something like: $_COOKIE['username'] = $username; $_COOKIE['password'] = $password; And then one of your users logs in on a public computer and his data is readable by any competent hacker that uses that computer after him Try any of the below options: session_cache_expire session_set_cookie_params Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1017986 Share on other sites More sharing options...
Rocu Posted February 25, 2010 Author Share Posted February 25, 2010 I already tried those commands. Didn't work. I think I'm still gonna stick with cookies, but I aint gonna set username and password inside the cookie, I'm just gonna put a md5-like hash to identify if the user's logged in or not. Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018122 Share on other sites More sharing options...
monkeytooth Posted February 25, 2010 Share Posted February 25, 2010 It also depends on your system settings, Is this a home brew server? Is it a hosting company (which)? Is it linux or windows based. What are your privilege settings for your hosting (if its home brew did you check your apache config make sure your session directory is set right, your time out for sessions on the server itself are set sometimes this can override your script commands.. Side note: for the hell of it.. try <?php print_r($_SESSION); ?> somewhere lower in your script (maybe the bottom of the page, and see if your sessions are being captured. Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018135 Share on other sites More sharing options...
Rocu Posted February 25, 2010 Author Share Posted February 25, 2010 I'm using hosting services from a local company: https://www.netpoint.ee/eng . Tried ur code and yes, they are being captured. Otherwise I couldn't log in. Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018143 Share on other sites More sharing options...
ignace Posted February 26, 2010 Share Posted February 26, 2010 Please post your code as the above command's should work you probably used them wrong Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018393 Share on other sites More sharing options...
Rocu Posted February 27, 2010 Author Share Posted February 27, 2010 It's not about my code, never has been. I got it to work by the way, partially atleast.. I had to make a new session folder manually in ftp. Now I set it to 5400 (1,5h) but it logs me out after 50 minutes. I'm happy with the 50 minutes already, but just curious, why won't it go all the way to 1,5h? Here are some values I wrote into htaccess: php_value session.gc_maxlifetime 5400 php_value session.cookie_lifetime 5400 php_value session.gc_divisor 1 php_value session.save_path /new_sessions/ Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018947 Share on other sites More sharing options...
ignace Posted February 27, 2010 Share Posted February 27, 2010 Are you on shared hosting? If so then you need to change the session save path using session_save_path you would get 50 minutes because the lowest value wins on a shared hosting. Edit: nevermind you already did that Quote Link to comment https://forums.phpfreaks.com/topic/193195-increasing-users-log-in-time/#findComment-1018967 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.