How to get cookie's expire time

前端 未结 6 563
小蘑菇
小蘑菇 2020-12-01 02:37

When I create a cookie, how to get cookie\'s expire time?

6条回答
  •  無奈伤痛
    2020-12-01 03:12

    To get cookies expire time, use this simple method.

    ";
        if(round(secToDays((intval($_COOKIE['testCookie']) - time())),1) < 1){
            echo "Cookie will expire today.";
        }else{
            echo "Cookie will expire in " . round(secToDays((intval($_COOKIE['testCookie']) - time())),1) . " day(s)";
        }
    
    }else{
        echo "not set...";
    }
    

    ?>

    You need to keep Part 1 and Part 2 in different files, otherwise you will get the same expire date everytime.

提交回复
热议问题