diff options
author | Florian Pritz <bluewind@xinu.at> | 2011-09-23 13:52:10 +0200 |
---|---|---|
committer | Florian Pritz <bluewind@xinu.at> | 2011-09-24 18:42:00 +0200 |
commit | c7d4e723417f3fad2a306af1f2053cdafde8af43 (patch) | |
tree | d696d25bf2a72e4ab03c378c65020220033407c1 /lib | |
parent | 037d0e9640e93e2df28963b7383562572ccbdd10 (diff) | |
download | nextcloud-server-c7d4e723417f3fad2a306af1f2053cdafde8af43.tar.gz nextcloud-server-c7d4e723417f3fad2a306af1f2053cdafde8af43.zip |
set cookie secure if forcessl is enabled
This also moves session_start in lib/base.php down a bit because we need
OC::$SERVERROOT to get the config settings.
Signed-off-by: Florian Pritz <bluewind@xinu.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/base.php | 6 | ||||
-rw-r--r-- | lib/user.php | 7 |
2 files changed, 8 insertions, 5 deletions
diff --git a/lib/base.php b/lib/base.php index ec6b2e98df0..de2e7a36eee 100644 --- a/lib/base.php +++ b/lib/base.php @@ -80,8 +80,6 @@ class OC{ date_default_timezone_set('Europe/Berlin'); ini_set('arg_separator.output','&'); - ini_set('session.cookie_httponly','1;'); - session_start(); // calculate the documentroot OC::$DOCUMENTROOT=realpath($_SERVER['DOCUMENT_ROOT']); @@ -102,6 +100,7 @@ class OC{ // redirect to https site if configured if( OC_Config::getValue( "forcessl", false )){ + ini_set("session.cookie_secure", "on"); if(!isset($_SERVER['HTTPS']) or $_SERVER['HTTPS'] != 'on') { $url = "https://". $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI']; header("Location: $url"); @@ -109,6 +108,9 @@ class OC{ } } + ini_set('session.cookie_httponly','1;'); + session_start(); + // Add the stuff we need always OC_Util::addScript( "jquery-1.6.4.min" ); OC_Util::addScript( "jquery-ui-1.8.14.custom.min" ); diff --git a/lib/user.php b/lib/user.php index 3e73b2f1008..241d9aa8b10 100644 --- a/lib/user.php +++ b/lib/user.php @@ -348,9 +348,10 @@ class OC_User { * @param string $username username to be set */ public static function setMagicInCookie($username, $token){ - setcookie("oc_username", $username, time()+60*60*24*15); - setcookie("oc_token", $token, time()+60*60*24*15); - setcookie("oc_remember_login", true, time()+60*60*24*15); + $secure_cookie = OC_Config::getValue("forcessl", false); + setcookie("oc_username", $username, time()+60*60*24*15, '', '', $secure_cookie); + setcookie("oc_token", $token, time()+60*60*24*15, '', '', $secure_cookie); + setcookie("oc_remember_login", true, time()+60*60*24*15, '', '', $secure_cookie); } /** |