开发者

How to clean PHP session on page unload?

I would like to know if calling via AJAX or jQuery or whatever the server side, can I clean a session var??

Nowdays I have a FB application that runs with PHP and it's behav开发者_C百科iour depends on a PHP session vars, and I would like to clean that session vars on the HTML event unload in the case that the user returns before the lifetime of those vars has passed.

Can it be done??


Presumably, because you are storing this information in session variables, you want it to persist between pages. Therefore, wouldn't clearing this information every time the user leaves a page defeat the purpose?

If you are referring to your PHP app in an iframe, and only clearing it when the user navigates away from the parent frame, I don't believe this can be done, if the parent frame is 'owned' by a different domain.


Yes, but for the static components on the calling page dependent upon session data will not be cleaned due to the stateless nature of the web. It would require a page refresh of some kind.

For example, if I clicked logout button that send an AJAX call to clear my session. I would technically still be logged into the originating page until I refreshed.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜