Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

179
Views
How to Set A Cookie Expiration Date To Another Cookie Value

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);
about 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!