summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--system/core/Input.php6
-rw-r--r--system/helpers/cookie_helper.php4
-rw-r--r--user_guide_src/source/changelog.rst2
-rw-r--r--user_guide_src/source/libraries/input.rst8
4 files changed, 11 insertions, 9 deletions
diff --git a/system/core/Input.php b/system/core/Input.php
index a7918aefb..0585b42fe 100644
--- a/system/core/Input.php
+++ b/system/core/Input.php
@@ -304,7 +304,7 @@ class CI_Input {
* @param bool $httponly Whether to only makes the cookie accessible via HTTP (no javascript)
* @return void
*/
- public function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
+ public function set_cookie($name, $value = '', $expire = 0, $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
if (is_array($name))
{
@@ -343,9 +343,9 @@ class CI_Input {
$httponly = config_item('cookie_httponly');
}
- if ( ! is_numeric($expire))
+ if ( ! is_numeric($expire) || $expire < 0)
{
- $expire = time() - 86500;
+ $expire = 1;
}
else
{
diff --git a/system/helpers/cookie_helper.php b/system/helpers/cookie_helper.php
index 30b475ce6..d069cdb15 100644
--- a/system/helpers/cookie_helper.php
+++ b/system/helpers/cookie_helper.php
@@ -59,7 +59,7 @@ if ( ! function_exists('set_cookie'))
*
* @param mixed
* @param string the value of the cookie
- * @param string the number of seconds until expiration
+ * @param int the number of seconds until expiration
* @param string the cookie domain. Usually: .yourdomain.com
* @param string the cookie path
* @param string the cookie prefix
@@ -67,7 +67,7 @@ if ( ! function_exists('set_cookie'))
* @param bool true makes the cookie accessible via http(s) only (no javascript)
* @return void
*/
- function set_cookie($name, $value = '', $expire = '', $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
+ function set_cookie($name, $value = '', $expire = 0, $domain = '', $path = '/', $prefix = '', $secure = FALSE, $httponly = FALSE)
{
// Set the config file options
get_instance()->input->set_cookie($name, $value, $expire, $domain, $path, $prefix, $secure, $httponly);
diff --git a/user_guide_src/source/changelog.rst b/user_guide_src/source/changelog.rst
index 74fb15798..a8467dcf1 100644
--- a/user_guide_src/source/changelog.rst
+++ b/user_guide_src/source/changelog.rst
@@ -24,6 +24,8 @@ Release Date: Not Released
- Removed previously deprecated ``$config['allow_get_array']``.
- Removed previously deprecated ``$config['standardize_newlines']``.
- Removed previously deprecated method ``is_cli_request()`` (use :php:func:`is_cli()` instead).
+ - Changed the ``set_cookie()`` method's default expiry time to 0 (expires when browser is closed).
+ - Changed the ``set_cookie()`` method to delete the cookie if a negative expiry time is passed to it.
- Libraries
diff --git a/user_guide_src/source/libraries/input.rst b/user_guide_src/source/libraries/input.rst
index 97460c2c5..aee39584a 100644
--- a/user_guide_src/source/libraries/input.rst
+++ b/user_guide_src/source/libraries/input.rst
@@ -242,7 +242,7 @@ Class Reference
This method is identical to ``get()``, ``post()`` and ``cookie()``,
only it fetches the *php://input* stream data.
- .. php:method:: set_cookie($name = ''[, $value = ''[, $expire = ''[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]])
+ .. php:method:: set_cookie($name = ''[, $value = ''[, $expire = 0[, $domain = ''[, $path = '/'[, $prefix = ''[, $secure = FALSE[, $httponly = FALSE]]]]]]])
:param mixed $name: Cookie name or an array of parameters
:param string $value: Cookie value
@@ -267,7 +267,7 @@ Class Reference
$cookie = array(
'name' => 'The Cookie Name',
'value' => 'The Value',
- 'expire' => '86500',
+ 'expire' => 86500,
'domain' => '.some-domain.com',
'path' => '/',
'prefix' => 'myprefix_',
@@ -278,8 +278,8 @@ Class Reference
**Notes**
- Only the name and value are required. To delete a cookie set it with the
- expiration blank.
+ Only the name and value are required. To delete a cookie set the expiry
+ time to a negative, or non-numeric value.
The expiration is set in **seconds**, which will be added to the current
time. Do not include the time, but rather only the number of seconds