-4

I am want to write a script to destroy all sessions on my browser currently running For Example: when script to destroy sessions is executed, If I am loggedin to facebook, gmail, yahoo or any other site, the login session should be destroyed. Thanks

Faisal Amjad
  • 33
  • 1
  • 6
  • 2
    No possible from JavaScript, what you want is basically the "delete all cookies" function that all browsers have. – bfavaretto Jun 20 '13 at 21:01
  • not all cookies, but what I specifically want is to force user logged out from a site when the script is executed – Faisal Amjad Jun 20 '13 at 21:04
  • Those sites use cookies to know that the user is logged in (and only they can read those cookies, they're domain-specific). – bfavaretto Jun 20 '13 at 21:07
  • 2
    as a browser question, this has nothing to do with PHP. As a question about deleting cookies, see http://stackoverflow.com/questions/2144386/javascript-delete-cookie – Mike 'Pomax' Kamermans Jun 20 '13 at 21:08
  • just to clarify: you want *your* web page to be able to affect the sessions of *other* sites? – Spudley Jun 20 '13 at 21:25

1 Answers1

2

Destroying session is something that happens within the server, iow the "server side code". When a session is started, a cookie is set in your browser. This cookie connects you to the session. If you want to simply "lose" the session in your browser, simply remove the cookie(s), but there is nothing you can do about Facebook still holding this session. Despite, once the cookie is destroyed in your browser, nobody can access that session (unless they have a copy of that cookie).

TravisO
  • 9,406
  • 4
  • 36
  • 44