There is no 1 for all solution and depends on application. If pages are cached there is no direct way to check if login session still exists, because I need PHP to verify it, so I send an AJAX request that can do that. If there is no session, but login cookie still exists unset this session...