From 42bd458dcaf2e7a61ca70a5b75900f22f26f78a7 Mon Sep 17 00:00:00 2001
From: Jeff Thomas <jeffmthomas@gmail.com>
Date: Sun, 20 Aug 2017 13:48:20 -0700
Subject: [PATCH] added withUrlEncode function

---
 src/Dflydev/FigCookies/SetCookie.php | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/src/Dflydev/FigCookies/SetCookie.php b/src/Dflydev/FigCookies/SetCookie.php
index 340a98d..88e5ef2 100644
--- a/src/Dflydev/FigCookies/SetCookie.php
+++ b/src/Dflydev/FigCookies/SetCookie.php
@@ -15,6 +15,7 @@ class SetCookie
     private $domain;
     private $secure = false;
     private $httpOnly = false;
+    private $urlEncode = false;
 
     private function __construct($name, $value = null)
     {
@@ -153,13 +154,28 @@ public function withHttpOnly($httpOnly = null)
 
         return $clone;
     }
+    
+    public function withUrlEncode($urlEncode = null)
+    {
+        $clone = clone($this);
+
+        $clone->urlEncode = $urlEncode;
+
+        return $clone;
+    }
 
     public function __toString()
     {
-        $cookieStringParts = [
-            urlencode($this->name).'='.urlencode($this->value),
-        ];
-
+        if($this->urlEncode){
+            $cookieStringParts = [
+                urlencode($this->name).'='.urlencode($this->value),
+            ];
+        }else{
+            $cookieStringParts = [
+                $this->name.'='.$this->value,
+            ];
+        }
+        
         $cookieStringParts = $this->appendFormattedDomainPartIfSet($cookieStringParts);
         $cookieStringParts = $this->appendFormattedPathPartIfSet($cookieStringParts);
         $cookieStringParts = $this->appendFormattedExpiresPartIfSet($cookieStringParts);