I have a site built with the PHP framework Yii and a cache table for search queries that are unique per user. I want to clear this cache as soon as the user has logged out, or their session have expired. I have an entry for the creation date and time of each search cache item.
If the user clicks logout, this is easy. I just clear their cache. But my problem is, how do I know if the session have expired if they don't click the logout button? I'm using the standard Yii user model, with sessions not stored in db but in files (I'm guessing PHP standard sessions is taking care of this).
How can I know for a given userId that have cached items that their session have expired ?