As you know we can read the name and value of a cookie, but we cannot read the cookie's expiration date and time. This is because when the browser sends cookie information to the server, it does not include the expiration information. One solution to get the expiry date is to set the cookie's expiration date to another cookie which can be read later to get the expiration date of first cookie.
Using JavaScript, I have create the first cookie like this
let username = 'geoca';
function setCookie(cName, cValue, expDays) {
let date = new Date();
date.setTime(date.getTime() + (expDays * 24 * 60 * 60 * 1000));
const expires = "expires=" + date.toUTCString();
document.cookie = cName + "=" + cValue + "; " + expires + "; path=/";
}
setCookie('webexia', username, 30);
now can you please let me know how can I get and set the expiry of webexia cookie (the first cookie) to getexpirey cookie in JavaScript or in PHP?
setCookie('getexpirey', ?????, 30);