Save the time in database.
To get time, use gettimeofday()
Alternative way:
If you don't feel like modifying the table structure, you could instead store the login time in a session variable, and when the user logs out, just subtract the login time session var from the current time (logout time).
When the user logs in, you could do
[PHP]session_start() ;
$_SESSION["login"] = time();
// rest of code[/PHP]
When the user logs out:
Alternative way:
If you don't feel like modifying the table structure, you could instead store the login time in a session variable, and when the user logs out, just subtract the login time session var from the current time (logout time).
When the user logs in, you could do
[PHP]session_start() ;
$_SESSION["login"] = time();
// rest of code[/PHP]
When the user logs out:
Comment