Welcome Guest, Not a member yet? Register   Sign In
Delete session from DB when closing browser
#3

[eluser]cmh24[/eluser]
First of all, thanks for your hint.

This is what I came up with
Code:
$(document).ready(function() {
<?php if($this->session->userdata('logged_in') == 1):?>

<?php $group_name= $this->session->userdata('group_name');?>
<?php $url = base_url().$group_name.'/settings/logout';?>

$(window).on('unload', function(){
  $.ajax({
   type : "POST",
   url : "<?php echo $url;?>",
   success: function()
   {
    alert('Success');  
   }
  });
});
<?php endif;?>
});

I did some research and found this.

The unload event is triggered when:

- a link to leave the page is clicked
- a new URL is typed in the address bar
- the forward or back buttons are used
- the browser window is closed
- the page is reloaded

Now I only want to trigger the event when the browser windows is closed.
So, what can I do?

Greetings!
Max


Messages In This Thread
Delete session from DB when closing browser - by El Forum - 05-24-2012, 05:32 PM
Delete session from DB when closing browser - by El Forum - 05-24-2012, 06:22 PM
Delete session from DB when closing browser - by El Forum - 05-25-2012, 02:11 AM
Delete session from DB when closing browser - by El Forum - 05-25-2012, 09:24 AM
Delete session from DB when closing browser - by El Forum - 05-28-2012, 12:00 AM



Theme © iAndrew 2016 - Forum software by © MyBB