+ Reply Thread
#1
I am using a Php script, so the problem is that any time a user login, after some minuites when the user tries to visit the site, it will logout the user.

Please how do I extend user Login session?
#2
Since session use browser cookie which is deleted after the browser is closed. You can simply extend the life of cookies for your site.
Code:
session_set_cookie_params(3600*24*7); session_start();

Note session_set_cookie_params is called before session_start

And the number passed above will make the session last a week. Replace the last number 7 with number of days you want or remove for just a day
#3
This is my code bro.

$_SESSION["user"]=$username;
$CookieExpire = 150;
$time = 60 * 60 * 24 * $CookieExpire;
$time = time() + $time;
$key = $username . date('mY');
$key = strtoupper(md5($key));
setcookie("sessionkey", "$key", "$time");
setcookie("user", "$username", "$time");
setcookie("password", "$password", "$time");
$id=functions::user_info($username, userID); $date=date();
$guestip=$_SERVER["REMOTE_ADDR"];
$guestbrowser=$_SERVER["HTTP_USER_AGENT"];
mysql_query("UPDATE b_guestsonline SET time=0 WHERE browser='$guestbrowser' AND guestip='$guestip'");
Back to top