slightly better reporting when setting rememberme cookies
darcs-hash:20081209175446-84dde-ae63433fa42debe8fb2eb3862cac0b9f81f1e6de.gz
This commit is contained in:
parent
7cbd2c4e1e
commit
60a43519b9
17
lib/util.php
17
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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user