how can i extend the cookie expiration time in php everytime i i regenerate the session id?

16,958

You should be able to update the expiration time with setcookie like:

setcookie("Cookiename", $value, NewExpirationTime)

Check if the Cookiename is exactly the same so that the old Cookie will be overwritten.

Share:
16,958
Abhishek
Author by

Abhishek

Updated on July 24, 2022

Comments

  • Abhishek
    Abhishek almost 2 years

    I have a session manager page: sessmgr.php. This page is supposed to validate the user log-in information, set the cookies and keep the session variables alive by updating the cookies expiration time and regenerating the session id by an XML HTTP request at regular intervals till the user logs out. I am able to update the session id but not extend the cookie expiration time.

    How to update the cookie expiration time here ??

  • Abhishek
    Abhishek over 10 years
    i found the mistake that was not letting the cookies to be updated. The cookie value i was trying to write was getting null just before writing the cookie as i was trying to use $_GLOBALS instead of $_SESSION array.
  • Bhavin Thummar
    Bhavin Thummar over 5 years
    @MarcelBalzer, Do you know Cookie will be not work from 2038? This is right? Because i have checked this link. stackoverflow.com/questions/3290424/…
  • A Friend
    A Friend over 5 years
    @MarcelBalzer well for now, yes, we're capped at 2038, but I think by the time we get to 2035 (if not sooner) we'll have implemented either a better system or converted to 64 bit so it's not really a concern