I don't know how to write php code for Stay logged in or remember me while user check the option while login. I want to stay user logged in at least 60min until user close the browser. What is the code for this in PHP.
Asked
Active
Viewed 3,196 times
2
-
Are you using sessions? Then this should be pretty much the default behavior. – deceze Feb 23 '11 at 07:14
-
@deceze: Yes i am using sessions – KillerFish Feb 23 '11 at 07:18
-
Please give me some code instead of links. :) – KillerFish Feb 23 '11 at 07:20
4 Answers
2
If you are using session. These threads will help you:
You can use session_set_cookie_params to set specific time of session life.
1
if you are using session, this would probably help
function lifetime(){
$inactive = 3600; //60 minutes, i suppose in seconds
if(isset($_SESSION['start']) ) {
$session_life = time() - $_SESSION['start'];
if($session_life > $inactive){
//your log out code
}
}
$_SESSION['start'] = time();
}
littlechad
- 1,202
- 17
- 48