I need to keep Security.level set on medium for Ajax reason. But I want that If the user close browser his session will destroy. How can I do that?
Thanks in advance!
I need to keep Security.level set on medium for Ajax reason. But I want that If the user close browser his session will destroy. How can I do that?
Thanks in advance!
Unless you're persisting session data (ie: storing session data in a cookie with an expiration date in the future), then the session should be destroyed when the user closes the browser.
Unfortunately I'm not familiar with the CakePHP framework so I cannot comment on its API. However, if you want to explicitly end a session you can do so in PHP with session_destroy()
.
Hope that helps.
i guess you could fire on ajax command on page unload to call session_destroy()
You could remove the session cookie with JS when the page is closed (remember: page close is also triggered when the user just navigates away - maybe just to the next page of yours).
http://book.cakephp.org/view/1317/destroy for CakePHP - but yes, CakePHP does set a proper session cookie which is deleted by the browser when it closes.
What you really are probably concerned about is session hijacking - and so you really want some kind of a logout on site closure. You can't do this - the best alternative method that I know of is:
Configure::write('Session.timeout', $seconds);
, where for medium security level the timeout seconds are multiplied by 100. Banks use this method.