aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_user.inc.php
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2006-07-28 09:34:27 +0000
committernikrou <nikrou@piwigo.org>2006-07-28 09:34:27 +0000
commit1873dbd0623cf61b95dedcbb0ee31bec416efd46 (patch)
treec74579a0827cab9d59414845edced3d66577fb44 /include/functions_user.inc.php
parentf6c2f2b1b11f6369beaf88b53efbb8afa64e2ca7 (diff)
Fix bug 451: improvement
small problem with reconnexion after session timeout add auto-login function all staff for session (connexion, auto-login and logout) is now in include/user.inc.php git-svn-id: http://piwigo.org/svn/trunk@1511 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_user.inc.php32
1 files changed, 31 insertions, 1 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 134f7493d..28f81e7a4 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -550,7 +550,7 @@ function get_language_filepath($filename)
*/
function log_user($user_id, $remember_me)
{
- global $conf;
+ global $conf, $user;
if ($remember_me)
{
@@ -581,6 +581,36 @@ UPDATE '.USERS_TABLE.'
}
session_start();
$_SESSION['pwg_uid'] = $user_id;
+
+ $user['id'] = $_SESSION['pwg_uid'];
+ $user['is_the_guest'] = false;
+}
+
+/*
+ * Performs auto-connexion when cookie remember_me exists
+ * @return void
+*/
+function auto_login() {
+ global $conf;
+
+ $cookie = unserialize(pwg_stripslashes($_COOKIE[$conf['remember_me_name']]));
+ $query = '
+SELECT auto_login_key
+ FROM '.USERS_TABLE.'
+ WHERE '.$conf['user_fields']['id'].' = '.$cookie['id'].'
+;';
+
+ $auto_login_key = current(mysql_fetch_assoc(pwg_query($query)));
+ if ($auto_login_key == $cookie['key'])
+ {
+ log_user($cookie['id'], false);
+ redirect(make_index_url());
+ }
+ else
+ {
+ setcookie($conf['remember_me_name'], '', 0, cookie_path());
+ redirect(make_index_url());
+ }
}
/*