remember me feature

This commit is contained in:
Andrew Dolgov 2006-03-04 11:58:25 +01:00
parent 377a3e8bfa
commit 5ccc1cf5d7
4 changed files with 24 additions and 5 deletions

View file

@ -108,7 +108,11 @@
// Bind sessions to specific IP address (requires DATABASE_BACKED_SESSIONS)
define('SESSION_COOKIE_LIFETIME', 0);
// In seconds, 0 means delete on browser close
// Default lifetime of a session cookie. In seconds,
// 0 means delete on browser close
define('SESSION_COOKIE_LIFETIME_REMEMBER', 3600);
// Session cookie lifetime if "remember me" is checked on login.
// vim:ft=php
?>

View file

@ -802,7 +802,10 @@
}
function logout_user() {
session_destroy();
session_destroy();
if (isset($_COOKIE[session_name()])) {
setcookie(session_name(), '', time()-42000, '/');
}
}
function get_script_urlpath() {

View file

@ -1,5 +1,5 @@
<?
require_once "sessions.php";
// require_once "sessions.php";
require_once "sanity_check.php";
require_once "version.php";
@ -20,6 +20,15 @@
$password = $_POST["password"];
if ($login && $password) {
if ($_POST["remember_me"]) {
session_set_cookie_params(SESSION_COOKIE_LIFETIME_REMEMBER);
} else {
session_set_cookie_params(SESSION_COOKIE_LIFETIME);
}
require "sessions.php";
if (authenticate_user($link, $login, $password)) {
initialize_user_prefs($link, $_SESSION["uid"]);
@ -65,7 +74,10 @@
<td><input name="login"></td></tr>
<tr><td align="right">Password:</td>
<td><input type="password" name="password"></td></tr>
<tr><td>&nbsp;</td><td>
<input type="checkbox" name="remember_me" id="remember_me">
<label for="remember_me">Remember me</label>
</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" class="button" value="Login">
</td></tr>

View file

@ -107,7 +107,7 @@
db_query($session_connection, $query);
}
session_set_cookie_params(SESSION_COOKIE_LIFETIME);
// session_set_cookie_params(SESSION_COOKIE_LIFETIME);
if (DATABASE_BACKED_SESSIONS) {
session_set_save_handler("open", "close", "read", "write", "destroy", "gc");