开发者

php session variables

开发者 https://www.devze.com 2022-12-22 07:43 出处:网络
I\'m working with sessions for the first time and why does the variable $session_life always = 0? $_SESSION[\'time\']开发者_如何学Python = time();

I'm working with sessions for the first time and why does the variable $session_life always = 0?

$_SESSION['time']开发者_如何学Python = time();
$inactive = 30;
$session_life = time() - $_SESSION['time'];


time() returns the current timestamp in seconds - less than a second has passed between the first and third lines. Try using microtime() instead:

http://us2.php.net/manual/en/function.microtime.php


If those expressions happen one after the other what you're doing is essentially:

time() - time();

which is likely to return 0.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号