summaryrefslogtreecommitdiffstats
path: root/system/core/Input.php
diff options
context:
space:
mode:
authortobiasbg <devnull@localhost>2011-02-18 21:57:13 +0100
committertobiasbg <devnull@localhost>2011-02-18 21:57:13 +0100
commit9aa7dc9c96baedf06afb443553a313297158f850 (patch)
treec2806b787ab971a253324f88355ecb7d5d4587b8 /system/core/Input.php
parent9b77fe3e39894af4816a662630c442ab89f16e31 (diff)
Bugfix in foreach-loop ('name' must be last, as it also is the array's name); consistent handling for 'cookie_secure' config item
Diffstat (limited to 'system/core/Input.php')
-rw-r--r--system/core/Input.php15
1 files changed, 7 insertions, 8 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index 25fe102b5..626245390 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -211,11 +211,12 @@ class CI_Input {
* @param bool true makes the cookie secure
* @return void
*/
- function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = NULL)
+ function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE)
{
if (is_array($name))
{
- foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name', 'secure') as $item)
+ // 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)
{
if (isset($name[$item]))
{
@@ -236,6 +237,10 @@ class CI_Input {
{
$path = config_item('cookie_path');
}
+ if ($secure == FALSE AND config_item('cookie_secure') != FALSE)
+ {
+ $secure = config_item('cookie_secure');
+ }
if ( ! is_numeric($expire))
{
@@ -246,12 +251,6 @@ class CI_Input {
$expire = ($expire > 0) ? time() + $expire : 0;
}
- // If TRUE/FALSE is not provided, use the config
- if ( ! is_bool($secure))
- {
- $secure = (bool) (config_item('cookie_secure') === TRUE);
- }
-
setcookie($prefix.$name, $value, $expire, $path, $domain, $secure);
}