Skip to content

Commit

Permalink
Cookies shall only be set "secure" when FlatPress is called via HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
azett committed Apr 20, 2024
1 parent ddfef97 commit ba890f3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 12 additions & 1 deletion defaults.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@

// supports Apache and IIS
$serverport = '';
if (isset($_SERVER ['HTTPS']) && ($_SERVER ['HTTPS'] == '1' || strtolower($_SERVER ['HTTPS']) == 'on')) {
if (is_https()) {
// HTTPS enabled
$serverport = "https://";
ini_set('session.cookie_httponly', 1);
Expand Down Expand Up @@ -178,3 +178,14 @@
#function _dummy() {}
#set_error_handler('_dummy');




/**
* Checks if FlatPress is called via HTTPS.
*
* @return boolean <code>true</code> when FlatPress is called via HTTPS; <code>false</code> otherwise.
*/
function is_https() {
return (isset($_SERVER ['HTTPS']) && ($_SERVER ['HTTPS'] == '1' || strtolower($_SERVER ['HTTPS']) == 'on'));
}
3 changes: 2 additions & 1 deletion fp-includes/core/core.cookie.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
function cookie_setup() {
global $fp_config;


// md5(BLOG_BASEURL);

if (!defined('COOKIEHASH'))
Expand All @@ -22,7 +23,7 @@ function cookie_setup() {
if (!defined('COOKIE_DOMAIN'))
define('COOKIE_DOMAIN', false);
if (!defined('COOKIE_SECURE'))
define('COOKIE_SECURE', true);
define('COOKIE_SECURE', is_https());
if (!defined('COOKIE_HTTPONLY'))
define('COOKIE_HTTPONLY', true);
}
Expand Down

0 comments on commit ba890f3

Please sign in to comment.