diff options
author | Andrey Andreev <narf@bofh.bg> | 2012-03-19 11:09:38 +0100 |
---|---|---|
committer | Andrey Andreev <narf@bofh.bg> | 2012-03-19 11:09:38 +0100 |
commit | cf10de5aa03bd7c0036a8347f22ace3089779092 (patch) | |
tree | 63c403df162d5d94ec11eb8f86949d4016fe4e4e /system/core/Input.php | |
parent | 25357cd7886b95d1e77b6a539a4588a265688874 (diff) | |
parent | 4ad0fd86e8dc6dba74305dbb0c88c593b46a19a2 (diff) |
Merge pull request #1182 from freewil/cookies-httponly
Cookies httponly
Diffstat (limited to 'system/core/Input.php')
-rwxr-xr-x | system/core/Input.php | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/system/core/Input.php b/system/core/Input.php index 901b4147e..6e6885992 100755 --- a/system/core/Input.php +++ b/system/core/Input.php @@ -228,7 +228,7 @@ class CI_Input { /** * Set cookie * - * Accepts six parameter, or you can submit an associative + * Accepts seven parameters, or you can submit an associative * array in the first parameter containing all the values. * * @param mixed @@ -238,14 +238,15 @@ class CI_Input { * @param string the cookie path * @param string the cookie prefix * @param bool true makes the cookie secure + * @param bool true makes the cookie accessible via http(s) only (no javascript) * @return void */ - public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE) + public function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE) { if (is_array($name)) { // always leave 'name' in last place, as the loop will break otherwise, due to $$item - foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'name') as $item) + foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'secure', 'httponly', 'name') as $item) { if (isset($name[$item])) { @@ -270,6 +271,10 @@ class CI_Input { { $secure = config_item('cookie_secure'); } + if ($httponly == FALSE && config_item('cookie_httponly') != FALSE) + { + $httponly = config_item('cookie_httponly'); + } if ( ! is_numeric($expire)) { @@ -280,7 +285,7 @@ class CI_Input { $expire = ($expire > 0) ? time() + $expire : 0; } - setcookie($prefix.$name, $value, $expire, $path, $domain, $secure); + setcookie($prefix.$name, $value, $expire, $path, $domain, $secure, $httponly); } // -------------------------------------------------------------------- |