diff --git a/lib/web/mage/cookies.js b/lib/web/mage/cookies.js index 34fb259b75718..ee47d69949ead 100644 --- a/lib/web/mage/cookies.js +++ b/lib/web/mage/cookies.js @@ -91,17 +91,18 @@ this.get = function (name) { var arg = name + '=', aLength = arg.length, - cLength = document.cookie.length, + cookie = document.cookie, + cLength = cookie.length, i = 0, j = 0; while (i < cLength) { j = i + aLength; - if (document.cookie.substring(i, j) === arg) { + if (cookie.substring(i, j) === arg) { return this.getCookieVal(j); } - i = document.cookie.indexOf(' ', i) + 1; + i = cookie.indexOf(' ', i) + 1; if (i === 0) { break; @@ -130,13 +131,14 @@ * @return {String} */ this.getCookieVal = function (offset) { - var endstr = document.cookie.indexOf(';', offset); + var cookie = document.cookie, + endstr = cookie.indexOf(';', offset); if (endstr === -1) { - endstr = document.cookie.length; + endstr = cookie.length; } - return decodeURIComponent(document.cookie.substring(offset, endstr)); + return decodeURIComponent(cookie.substring(offset, endstr)); }; return this;