aboutsummaryrefslogtreecommitdiffstats
path: root/include/functions_user.inc.php
diff options
context:
space:
mode:
authorrvelices <rv-github@modusoptimus.com>2008-10-16 00:35:30 +0000
committerrvelices <rv-github@modusoptimus.com>2008-10-16 00:35:30 +0000
commitf7f8c1688ef30ecb2f40fe279ba34d250d4ec8be (patch)
tree8d6fde76195c05586163fd33ed9df706367c30aa /include/functions_user.inc.php
parent7807d6586a198c75e3d4f72c4b360bee061b817f (diff)
- security paranoia: protect session/remember me cookies from XSS attacks (works only if php>=5.2 and with IE/FF maybe others)
git-svn-id: http://piwigo.org/svn/branches/2.0@2756 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to '')
-rw-r--r--include/functions_user.inc.php34
1 files changed, 30 insertions, 4 deletions
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 02aa2a5d8..074a8aae9 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -1013,16 +1013,28 @@ function log_user($user_id, $remember_me)
if ($key!==false)
{
$cookie = $user_id.'-'.$now.'-'.$key;
- setcookie($conf['remember_me_name'],
+ if (version_compare(PHP_VERSION, '5.2', '>=') )
+ {
+ setcookie($conf['remember_me_name'],
+ $cookie,
+ time()+$conf['remember_me_length'],
+ cookie_path(),ini_get('session.cookie_domain'),ini_get('session.cookie_secure'),
+ ini_get('session.cookie_httponly')
+ );
+ }
+ else
+ {
+ setcookie($conf['remember_me_name'],
$cookie,
time()+$conf['remember_me_length'],
- cookie_path()
+ cookie_path(),ini_get('session.cookie_domain'),ini_get('session.cookie_secure')
);
+ }
}
}
else
{ // make sure we clean any remember me ...
- setcookie($conf['remember_me_name'], '', 0, cookie_path());
+ setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
}
if ( session_id()!="" )
{ // we regenerate the session for security reasons
@@ -1062,7 +1074,7 @@ function auto_login() {
return true;
}
}
- setcookie($conf['remember_me_name'], '', 0, cookie_path());
+ setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
}
return false;
}
@@ -1092,6 +1104,20 @@ SELECT '.$conf['user_fields']['id'].' AS id,
return false;
}
+/** Performs all the cleanup on user logout */
+function logout_user()
+{
+ global $conf;
+ $_SESSION = array();
+ session_unset();
+ session_destroy();
+ setcookie(session_name(),'',0,
+ ini_get('session.cookie_path'),
+ ini_get('session.cookie_domain')
+ );
+ setcookie($conf['remember_me_name'], '', 0, cookie_path(),ini_get('session.cookie_domain'));
+}
+
/*
* Return user status used in this library
* @return string