How to get value store in cookie in browser by use simply jQuery

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">

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;
var getArrayGASplit = getSourceCookie[1].split(".");

var getSourceCookie = getArrayGASplit[2]+'.'+getArrayGASplit[3];