PHP When the session expires, it redirects the entire page instead of the page loaded via ajax


I have a php page that uses php sessions as well as jquery to call pages via ajax. The problem is if the page is idle for so long the page being called via ajax gets redirected to the home page but the rest of the page outside the div being updated with the ajax still shows the person logged in until they try to click a link then the whole page redirects to the login page since the session has timed out. Is there a way in php that once it detects the session has timed out then redirects them to the logout page that the whole page gets redirected instead of just the page being called via ajax? Perhaps a solution via jquery could work? Hope this makes sense.

you can detect the session is timed out or not in php. If it is timed out, just return,

echo "<script>'$url'</script>";

where $url is your redirection url.