From 5ccc1cf5d763251fb1c8029cfd4e9f81e614a3a2 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 4 Mar 2006 11:58:25 +0100 Subject: [PATCH] remember me feature --- config.php-dist | 6 +++++- functions.php | 5 ++++- login.php | 16 ++++++++++++++-- sessions.php | 2 +- 4 files changed, 24 insertions(+), 5 deletions(-) diff --git a/config.php-dist b/config.php-dist index b6131318..7787727b 100644 --- a/config.php-dist +++ b/config.php-dist @@ -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 ?> diff --git a/functions.php b/functions.php index 8822cb35..acbc3d31 100644 --- a/functions.php +++ b/functions.php @@ -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() { diff --git a/login.php b/login.php index bfdce9a6..40cee399 100644 --- a/login.php +++ b/login.php @@ -1,5 +1,5 @@ Password: - +   + + + diff --git a/sessions.php b/sessions.php index 42877ffe..8d46f3f5 100644 --- a/sessions.php +++ b/sessions.php @@ -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"); -- 2.39.2