Question

I need to have my web app destroy/unset the Zend_Auth session when a user leaves the site: for example when a user navigates away from myapp.com to say google.com, when they come back the session is no longer set?

Preferable to allow refresh without unsetting (but not essential as the first part must apply).

Anyone had experience with doing this before?

Was it helpful?

Solution

Make an ajax call before unloading the page, that clears the identity of the Zend Auth

<script language="JavaScript">
        window.onbeforeunload = function(){
        $.get('http://example.com/auth/clear');
    }
</script>

ServerSide:

public function clearAction(){
    Zend_Auth::getInstance()->clearIdentity();
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top