开发者

how to set different time out limit for different sessions in php

Can we set diff time out limit for diff session variables in php?

开发者_运维知识库For eg: $var1 = $_SESSION['var1'];

$var2 = $_SESSION['var2'];

I want $_SESSION['var1'] to expire after 5 mins while $_SESSION['var2'] should expire after 30 mins..

Thanks


Nope, this is not possible natively.

You will have to implement this on your own. You would have to store creation date, expiry time, and value for every variable, and then maybe create a class that handles the checking.

You could use the __get() and __set() magic methods to build a very convenient interface that handles like this:

$data = new SessionData();
echo $data->var1; // Using a __get() magic method, the class checks for 
                  // the expiry time and returns the value if it is still valid
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜