Page 1 of 1

How to end a session with a click?

Posted: Wed Mar 22, 2006 1:24 am
by Citizen
What code would I need to run in order to allow the user to click a button and end the session to log out?

Thanks,
-Cit

Posted: Wed Mar 22, 2006 1:37 am
by feyd
To really log out, they would need (at least) an interaction with the server so it can destroy the session data associated with them. The quick and dirty log out would use Javascript to erase the browser's session cookie reference and change the URL to not have the session id in it.

Posted: Wed Mar 22, 2006 2:01 am
by Citizen
So I'd have to use a form?

Posted: Wed Mar 22, 2006 2:07 am
by feyd
Not absolutely. The URL you hit could be specifically built to destory the session data, or know to destroy it from the request data, or some other such things.

Posted: Wed Mar 22, 2006 2:24 am
by Citizen
So it would be a good idea to have a link like http://link.com/logout?log=out and open it in _blank with the end session code in it?

Posted: Wed Mar 22, 2006 2:26 am
by feyd
provided your script responds to such a url, sure, although _blank isn't needed..