]> git.wh0rd.org Git - tt-rss.git/commitdiff
remember me feature
authorAndrew Dolgov <fox@bah.spb.su>
Sat, 4 Mar 2006 10:58:25 +0000 (11:58 +0100)
committerAndrew Dolgov <fox@bah.spb.su>
Sat, 4 Mar 2006 10:58:25 +0000 (11:58 +0100)
config.php-dist
functions.php
login.php
sessions.php

index b61313183bf8f59eb9043e849898b80e055a4f7b..7787727b0290ffa7699a7629d41a57baa3899adb 100644 (file)
        // 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
 ?>
index 8822cb35eac4f04a60863867d56077adffa29e62..acbc3d31e111fbc79d112d5d1a5c58e240be05d3 100644 (file)
        }
 
        function logout_user() {
-               session_destroy();              
+               session_destroy();
+               if (isset($_COOKIE[session_name()])) {
+                  setcookie(session_name(), '', time()-42000, '/');
+               }
        }
 
        function get_script_urlpath() {
index bfdce9a6dc00c7640e3dbeeecfd169411be60cdc..40cee399bd23d2e8210da1fa789371dceea1ae29 100644 (file)
--- a/login.php
+++ b/login.php
@@ -1,5 +1,5 @@
 <?
-       require_once "sessions.php";
+//     require_once "sessions.php";
 
        require_once "sanity_check.php";
        require_once "version.php"; 
        $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"]); 
                        
                <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>
index 42877ffec7e884ae5d7a75d1bf721af4e67cb6ff..8d46f3f56869c3ad205686fb778aecc2de2003d1 100644 (file)
                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");