I use below code buts not returning the expiry date and time of cookie.
function getCookie(cookieName) {
var name = cookieName + "=";
var decodedCookie = decodeURIComponent(document.cookie);
var cookieArray = decodedCookie.split(';');
for (var i = 0; i < cookieArray.length; i++) {
var cookie = cookieArray[i];
while (cookie.charAt(0) === ' ') {
cookie = cookie.substring(1);
}
if (cookie.indexOf(name) === 0) {
return cookie.substring(name.length, cookie.length);
}
}
return "";
}
function getCookieExpiration(cookieValue) {
var expirationIndex = cookieValue.indexOf(";expires=");
if (expirationIndex === -1) {
return null;
}
var expirationString = cookieValue.substring(expirationIndex + 9);
return new Date(expirationString);
}
$(document).ready(function() {
var cookieValue = getCookie("ServiceMate-CookieShow");
var cookieExpiration = getCookieExpiration(cookieValue);
if (cookieExpiration !== null) {
alert("Cookie Expiry Date: " + cookieExpiration);
// Perform further actions with the cookie expiry date
}
alert("Cookie Expiry Date: ");
});