From 2533fe5a5e4eda95837b9e303478277fd7605ef1 Mon Sep 17 00:00:00 2001 From: Andrew Welch Date: Wed, 6 Apr 2016 21:51:32 -0400 Subject: [PATCH] Saner default values for cookies --- CookiesPlugin.php | 2 +- README.md | 9 +++++++-- releases.json | 9 +++++++++ services/Cookies_UtilsService.php | 4 ++-- twigextensions/CookiesTwigExtension.php | 4 ++-- variables/CookiesVariable.php | 4 ++-- 6 files changed, 23 insertions(+), 9 deletions(-) diff --git a/CookiesPlugin.php b/CookiesPlugin.php index d2e99f3..224c9b2 100755 --- a/CookiesPlugin.php +++ b/CookiesPlugin.php @@ -25,7 +25,7 @@ public function getReleaseFeedUrl() public function getVersion() { - return '1.0.3'; + return '1.0.4'; } public function getSchemaVersion() diff --git a/README.md b/README.md index da08227..3f2c250 100755 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ They all act as a wrapper for the PHP `setcookie` function: More info: (http://php.net/manual/en/function.setcookie.php) -All of the parameters except for `NAME` are optional. The `DOMAIN` defaults to `/` +All of the parameters except for `NAME` are optional. The `PATH` defaults to `/` if not specified **Examples** @@ -56,7 +56,7 @@ All three of these methods accomplish the same thing: This function works the same as `setCookie` but instead of using the PHP `setcookie` function, it uses the `craft()->request->getCookies()->add` to add the cookies via Craft. It also utilizes `craft->security` framework to encrypt and validate the cookie contents between requests. -All of the parameters except for `NAME` are optional. +All of the parameters except for `NAME` are optional. The `PATH` defaults to `/` if not specified **Examples** @@ -158,6 +158,11 @@ All three of these methods accomplish the same thing: ## Changelog +### 1.0.4 -- 2016.04.06 + +* [Fixed] Saner default values for cookies +* [Improved] Updated the README.md + ### 1.0.3 -- 2016.03.08 * [Fixed] We now set the expiration date to the past if we're deleting a cookie, to force browsers to remove it diff --git a/releases.json b/releases.json index e791316..e1f3e0a 100644 --- a/releases.json +++ b/releases.json @@ -1,4 +1,13 @@ [ + { + "version": "1.0.4", + "downloadUrl": "https://github.com/khalwat/cookies/archive/master.zip", + "date": "2016-04-06T11:00:00-05:00", + "notes": [ + "[Fixed] Saner default values for cookies", + "[Improved] Updated the README.md" + ] + }, { "version": "1.0.3", "downloadUrl": "https://github.com/khalwat/cookies/archive/master.zip", diff --git a/services/Cookies_UtilsService.php b/services/Cookies_UtilsService.php index 542af24..4c59666 100644 --- a/services/Cookies_UtilsService.php +++ b/services/Cookies_UtilsService.php @@ -8,7 +8,7 @@ class Cookies_UtilsService extends BaseApplicationComponent Standard cookies -------------------------------------------------------------------------------- */ - public function set($name = "", $value = "", $expire = 0, $path = "", $domain = "/", $secure = false, $httponly = false) + public function set($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { $expire = (int) $expire; /* -- Make sure the cookie expiry is in the past if we're deleting the cookie */ @@ -28,7 +28,7 @@ public function get($name = "") Security validated cookies -------------------------------------------------------------------------------- */ - public function setSecure($name = "", $value = "", $expire = 0, $path = "", $domain = "/", $secure = false, $httponly = false) + public function setSecure($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { if ($name == "") { diff --git a/twigextensions/CookiesTwigExtension.php b/twigextensions/CookiesTwigExtension.php index 00e4c43..94c6f1e 100644 --- a/twigextensions/CookiesTwigExtension.php +++ b/twigextensions/CookiesTwigExtension.php @@ -44,7 +44,7 @@ public function getFunctions() Filters -------------------------------------------------------------------------------- */ - public function setCookie_filter($name = "", $value = "", $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false) + public function setCookie_filter($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { craft()->cookies_utils->set($name, $value, $expire, $path, $domain, $secure, $httponly); } /* -- setCookie_filter */ @@ -54,7 +54,7 @@ public function getCookie_filter($name) return craft()->cookies_utils->get($name); } /* -- getCookie_filter */ - public function setSecureCookie_filter($name = "", $value = "", $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false) + public function setSecureCookie_filter($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { craft()->cookies_utils->setSecure($name, $value, $expire, $path, $domain, $secure, $httponly); } /* -- setSecureCookie_filter */ diff --git a/variables/CookiesVariable.php b/variables/CookiesVariable.php index da9e317..0c93771 100755 --- a/variables/CookiesVariable.php +++ b/variables/CookiesVariable.php @@ -8,7 +8,7 @@ class CookiesVariable Variables -------------------------------------------------------------------------------- */ - function set($name = "", $value = "", $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false) + function set($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { craft()->cookies_utils->set($name, $value, $expire, $path, $domain, $secure, $httponly); } /* -- set */ @@ -18,7 +18,7 @@ function get($name) return craft()->cookies_utils->get($name); } /* -- get */ - function setSecure($name = "", $value = "", $expire = 0, $path = "", $domain = "", $secure = false, $httponly = false) + function setSecure($name = "", $value = "", $expire = 0, $path = "/", $domain = "", $secure = false, $httponly = false) { craft()->cookies_utils->setSecure($name, $value, $expire, $path, $domain, $secure, $httponly); } /* -- setSecure */