Get Value store Cookie into Chrome or other Web Browser with JQuery Easily.
Below the code, describe how to store a specified cookie value into a variable and use it for further use. Cookie ‘_ga’ store in web browsers such as Chrome or Firefox, with using the jQuery get the value of cookie and store into JavaScript variable (‘_ga== in below code’).
<script type="text/javascript"> jQuery(document).ready(function(){ console.log('Get Cookie Value GA'); var getCookieAllGa = document.cookie.split(';'); for(var i = 0; i < getCookieAllGa.length; i++){ var cookiePairGa = getCookieAllGa[i].split("="); //define your cookie name with replace of _ga text. if('_ga' == cookiePairGa[0].trim()){ var getSourceCookie = cookiePairGa; console.log(getSourceCookie); var getArrayGASplit = getSourceCookie[1].split("."); console.log(getArrayGASplit); var getSourceCookie = getArrayGASplit[2]+'.'+getArrayGASplit[3]; console.log(getSourceCookie); jQuery('#getGAId').val(getSourceCookie); } } }); </script>