How can I specify / code that a user that has been inactive for a certain amount of time needs to be re-authenticated ?

I know there is a timeout for the user cache, but to my knowledge that is independant on whether the user has been online and does not represent the user a login screen.