1function checkCookie(cookieName) { 2 // Get the cookie string 3 var cookies = document.cookie; 4 5 // Split the cookie string into individual cookies 6 var cookieList = cookies.split('; '); 7 8 // Look for the specified cookie name followed by '=' 9 var cookiePrefix = cookieName + "="; 10 11 // Check each cookie to see if it's the one we're looking for 12 for(var i = 0; i < cookieList.length; i++) { 13 var cookie = cookieList[i]; 14 15 // If the cookie begins with the name we're looking for, it's present 16 if (cookie.startsWith(cookiePrefix)) { 17 return true; 18 } 19 } 20 21 // If we didn't find the cookie, return false 22 return false; 23} 24 25// Usage: Check if 'dismissSignupPopup' cookie is set 26// var isCookieSet = checkCookie('dismissSignupPopup'); 27// console.log(isCookieSet); // Outputs true if the cookie exists, false otherwise
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.