function getCookie(cname) {
var name = cname + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var ca = decodedCookie.split(';');
for(var i = 0; i < ca.length; i++) {
var c = ca[i];
while (c.charAt(0) == ' ') {
c = c.substring(1);
}
if (c.indexOf(name) === 0) {
return c.substring(name.length, c.length);
}
}
return "";
}
// Data to store
var LastReportGenerated="Jul 11 2013",
// Get the top level domain and assign as .domain.com
baseDomain = '.cssjunction.com', //your domain must be in format of '.domain.com' – dot and root domain
// Set Expires (optional)
expireAfter = new Date();
expireAfter.setDate(expireAfter.getDate() + 7); //setting up cookie expire date after a week
// Now setup cookie
document.cookie="Report={'ReportName':'MainReport', 'lastGenerated':" + LastReportGenerated + "}; domain=" + baseDomain + "; expires=" + expireAfter + "; path=/"; // 'path=/'' always. If you don’t setup your path=/, auto path will be saved as from where the cookies is being saved hence it wont be accessible across any subdomain.