remove all session of user with onclick close button of browser

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oranoos3000
    New Member
    • Jan 2009
    • 107

    remove all session of user with onclick close button of browser

    hi
    i d like to when user click the close button all session of the user remover from the system
    i user ajax fuction ajax that with onunload is called but result i want dont earn
    thanks alot
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    remove the session cookie.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      Hey.

      Try the onbeforeunload event.

      Comment

      • oranoos3000
        New Member
        • Jan 2009
        • 107

        #4
        hi
        would you please descibe with more details

        Comment

        • Atli
          Recognized Expert Expert
          • Nov 2006
          • 5062

          #5
          You could use the onbeforeunload event to execute an AJAX request for a PHP file that would clear whatever sessions stuff you want cleared.

          For example, using jQuery for the AJAX stuff:

          index.html
          [code=javascript]window.onbefore unload = function() {
          $.get('clear_se ssion.php');
          return 'The sessions have been cleared!';
          }[/code]

          clear_session.p hp
          [code=php]<?php
          session_start() ;
          session_destroy ();
          ?>[/code]

          This would bring up a prompt when the window or tab is closed, asking if the user really wants to close it. Meanwhile, the AJAX request is sent and the PHP code executed, clearing the session.

          Comment

          Working...