0

so I call the zend auth clear identity function through ajax and if the ajax returns true (ie the identity got cleared), i just reload the browser through location.reload()

and what usually happens is that the page has the following:

if ($this->auth->hasIdentity()) {

     echo "Welcome";

}

and

if (!$this->auth->hasIdentity()) {

     echo "some login form";

}

but then since the page is cached by the browser....even though I've called the logout script through ajax (which clears the identity) and reload the page, the page still displays the welcome screen since it thinks that the page hasn't changed and so just displays the cache which contains the welcome screen rather than the login form when it's reloaded......

is there away to clear the cache manually or some sort using jquery so that it won't just load up the cache when reloaded?

kamikaze_pilot
  • 14,304
  • 35
  • 111
  • 171

2 Answers2

0

I may be wrong, but wouldn't that be more of a caching issue in general? Tell the browser not to cache that specific page and the problem should be solved.

wanovak
  • 6,117
  • 25
  • 32
0

My recommendation is to not make your logout functionality Ajax. Just make it a regular link like: /authentication/logout/

That action should do this:

public function logoutAction() {
        $auth = Zend_Auth::getInstance();
        $auth->clearIdentity();
        $this->_redirect('/authentication/login');
}

That works for me, anyway.

I understand this may not be an ideal answer, but I would still challenge the need for the logout link to be ajax.

Simon Lang
  • 40,171
  • 9
  • 49
  • 58