diff --git a/libraries/HTTPClient/src/HTTPClient.cpp b/libraries/HTTPClient/src/HTTPClient.cpp
index 7e967be9f35..4982503a7fd 100644
--- a/libraries/HTTPClient/src/HTTPClient.cpp
+++ b/libraries/HTTPClient/src/HTTPClient.cpp
@@ -1551,8 +1551,6 @@ void HTTPClient::setCookie(String date, String headerValue)
     String value;
     int pos1, pos2;
 
-    headerValue.toLowerCase();
-
     struct tm tm;
     strptime(date.c_str(), HTTP_TIME_PATTERN, &tm);
     cookie.date = mktime(&tm);
@@ -1567,6 +1565,9 @@ void HTTPClient::setCookie(String date, String headerValue)
         return;     // invalid cookie header
     }
 
+    // only Cookie Attributes are case insensitive from this point on
+    headerValue.toLowerCase();
+
     // expires
     if (headerValue.indexOf("expires=") >= 0){
         pos1 = headerValue.indexOf("expires=") + strlen("expires=");