Re: Zhang Session Expiration

From: Date: Mon, 07 Jan 2002 13:48:39 +0000
Subject: Re: Zhang Session Expiration
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-79690@lists.php.net to get a copy of this message
At 07:20 AM 1/7/2002 -0600, phantom wrote:
Hey all, I am using the Zhang session method from http://www.phpbuilder.com/columns/ying20000602.php3 and it works great with a mysql database. Does anyone out there know how to tell if a session is expired using this method?
Yep. The "expiry" field is equal to the UNIX timestamp at which the session will expire. To get a list of sessions that have already expired, you can use this: $query = "SELECT * FROM sessions WHERE expiry < " . time();
Say I had placed a variable called $NameOfUser in the session data using session_register($NameOfUser), if the session is expired, would I be able to know that it was expired by using isset($NameOfUser) after running the session_register($NameOfUser) in the script??
That sounds about right. You might want to try: if (!session_is_registered("NameOfUser")) {
        //restart session
} Although I don't know if that function is reliable with the custom session handler...I think it should be though. I've been using that exact same session handler for several weeks in one of my scripts and it works great....

« previous php.general (#79690) next »