how to fix a timer in the session as like if the user didnt log out auto matically log out after a required time how to make it can ay body help me
| SitePoint Sponsor |

how to fix a timer in the session as like if the user didnt log out auto matically log out after a required time how to make it can ay body help me
The word is "doubt" okay?
Second the timer doesn't go in the session's data. It has to go into a place that all sessions could access it. But there is no need for that anyways as PHP's garbage collection with remove old sessions.

no friend i have one site where how can fix a timer for the loging out like unfortunately the user didnt loged out means it should auto maticlly loged out after a few min so can we develope it through progrm wise can u help me if u can pls ok thnk for ur english
PHP's garbage collection will handle users who have not logged out. Just as I said previously.
Or do you mean logged out as in on a database?
In which case you should have a field for 'last activity', rather than a 'logged in' field. Then, to see if they're logged in, see if their last activity is in the last $time seconds.
For example:
Not very sure with the date functions in MySQL, so there may be a better way... (enter Rudy...)PHP Code:define('LOGGED_IN_LIMIT', 2 * 60 * 60); //2 hours
function isLoggedIn($Username){
$Username = MySQL_Real_Escape_String($Username);
$Limit = LOGGED_IN_LIMIT;
$Query = MySQL_Query("SELECT 1 FROM Users WHERE Username = '{$Username}' AND (UNIX_TIMESTAMP() - UNIX_TIMESTAMP(LastActivity)) <= {$Limit}");
return (MySQL_Num_Rows($Query) > 0);
}
Jake Arkinstall
"Sometimes you don't need to reinvent the wheel;
Sometimes its enough to make that wheel more rounded"-Molona
Bookmarks