How to print session time remaining in php?

后端 未结 1 375
[愿得一人]
[愿得一人] 2021-01-16 11:33

I have a program in PHP and I want to print to the screen how much time the user has until their session expires. I want it to update when they reload the page.

For

1条回答
  •  粉色の甜心
    2021-01-16 12:17

    You can set a cookie with the UNIX time and compare with that.

    setcookie("start", time(), time ()+3600); // saves a cookie with current UNIX time for one hour
    

    Read about setcookie here http://php.net/manual/en/function.setcookie.php
    If you never used it before, be sure to read the begining carefully.

    And compare time like:

    If (isset($_COOKIE["start"]) and $_COOKIE["start"]+3600

    0 讨论(0)
提交回复
热议问题