summaryrefslogtreecommitdiff
path: root/lib/util.php
diff options
context:
space:
mode:
authorEvan Prodromou <evan@prodromou.name>2008-12-09 12:54:46 -0500
committerEvan Prodromou <evan@prodromou.name>2008-12-09 12:54:46 -0500
commit60a43519b9c1a66265d5374dec98bf0dae7095db (patch)
tree9e0d01e55015606309e28ad470c35e2b6bb0974c /lib/util.php
parent7cbd2c4e1eafb9067e3ceab30a4111b20a3442a7 (diff)
slightly better reporting when setting rememberme cookies
darcs-hash:20081209175446-84dde-ae63433fa42debe8fb2eb3862cac0b9f81f1e6de.gz
Diffstat (limited to 'lib/util.php')
-rw-r--r--lib/util.php19
1 files changed, 13 insertions, 6 deletions
diff --git a/lib/util.php b/lib/util.php
index 2484ae6b6..87a6a42c5 100644
--- a/lib/util.php
+++ b/lib/util.php
@@ -602,7 +602,7 @@ function common_set_cookie($key, $value, $expiration=0) {
}
define('REMEMBERME', 'rememberme');
-define('REMEMBERME_EXPIRY', 30 * 24 * 60 * 60);
+define('REMEMBERME_EXPIRY', 30 * 24 * 60 * 60); # 30 days
function common_rememberme($user=NULL) {
if (!$user) {
@@ -612,19 +612,26 @@ function common_rememberme($user=NULL) {
return false;
}
}
+
$rm = new Remember_me();
$rm->code = common_good_rand(16);
$rm->user_id = $user->id;
$result = $rm->insert();
+
if (!$result) {
common_log_db_error($rm, 'INSERT', __FILE__);
common_debug('Error adding rememberme record for ' . $user->nickname, __FILE__);
return false;
- }
- common_log(LOG_INFO, 'adding rememberme cookie for ' . $user->nickname);
- common_set_cookie(REMEMBERME,
- implode(':', array($rm->user_id, $rm->code)),
- time() + REMEMBERME_EXPIRY);
+ }
+
+ common_debug('Inserted rememberme record (' . $rm->code . ', ' . $rm->user_id . '); result = ' . $result . '.', __FILE__);
+
+ $cookieval = $rm->user_id . ':' . $rm->code;
+
+ common_log(LOG_INFO, 'adding rememberme cookie "' . $cookieval . '" for ' . $user->nickname);
+
+ common_set_cookie(REMEMBERME, $cookieval, time() + REMEMBERME_EXPIRY);
+
return true;
}