From 37bf1f889bd41c6ca1ea7eae2d13aecd51218026 Mon Sep 17 00:00:00 2001
From: Andrea Scarpino <bash.lnx@gmail.com>
Date: Tue, 8 Jul 2008 18:56:42 +0200
Subject: [PATCH] remember user between sessions

---
 web/lang/en/index_po.inc    |    2 ++
 web/lang/it/index_po.inc    |    4 +++-
 web/lib/acctfuncs.inc       |    6 +++++-
 web/template/login_form.php |    1 +
 4 files changed, 11 insertions(+), 2 deletions(-)

diff --git a/web/lang/en/index_po.inc b/web/lang/en/index_po.inc
index bdeb87f..eb626eb 100644
--- a/web/lang/en/index_po.inc
+++ b/web/lang/en/index_po.inc
@@ -25,6 +25,8 @@ $_t["en"]["Password:"] = "Password:";
 
 $_t["en"]["Username:"] = "Username:";
 
+$_t["en"]["Remember me"] = "Remember me";
+
 $_t["en"]["Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h."] = "Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h.";
 
 $_t["en"]["This is where the intro text will go."] = "This is where the intro text will go.";
diff --git a/web/lang/it/index_po.inc b/web/lang/it/index_po.inc
index f1e54eb..a7b9c12 100644
--- a/web/lang/it/index_po.inc
+++ b/web/lang/it/index_po.inc
@@ -19,6 +19,8 @@ $_t["it"]["Password:"] = "Password:";
 
 $_t["it"]["Username:"] = "Nome utente:";
 
+$_t["it"]["Remember me"] = "Ricordami" ;
+
 $_t["it"]["Welcome to the AUR! If you're a newcomer, you may want to read the %hGuidelines%h."] = "Benvenuto in AUR! Se sei un nuovo utente, dovresti leggere le %hGuidelines%h.";
 
 $_t["it"]["This is where the intro text will go."] = "Qui ci andrà il testo di introduzione.";
diff --git a/web/lib/acctfuncs.inc b/web/lib/acctfuncs.inc
index bbd6b74..803967b 100644
--- a/web/lib/acctfuncs.inc
+++ b/web/lib/acctfuncs.inc
@@ -644,7 +644,11 @@ function try_login() {
 			if ($logged_in) {
 				# set our SID cookie
 
-				setcookie("AURSID", $new_sid, 0, "/");
+				if ($_POST['remember_me'] == "on")
+					$cookie_time = time() + (60 * 60 * 24 * 30); // Set cookies for 30 days
+				else
+					$cookie_time = 0;
+				setcookie("AURSID", $new_sid, $cookie_time, "/");
 #				header("Location: /index.php");
 				header("Location: " . $_SERVER['PHP_SELF'].'?'.$_SERVER['QUERY_STRING']);
 				$login_error = "";
diff --git a/web/template/login_form.php b/web/template/login_form.php
index b2ed066..921011c 100644
--- a/web/template/login_form.php
+++ b/web/template/login_form.php
@@ -16,6 +16,7 @@
       } ?>" />
     <label><?php print __("Password:"); ?></label>
     <input type="password" name="passwd" size="30" maxlength="<?php print PASSWD_MAX_LEN; ?>" />
+    <input type="checkbox" name="remember_me"> <?php print __("Remember me"); ?>
     <input type="submit" class="button" value="<?php  print __("Login"); ?>" />
   </form>
   <?php } ?>
-- 
1.5.6.2

