title: How to update user list while a user entering/leaving a page?
body: <p>I'm working on a chat application in which i want to detect and fire ajax when a user leaving a page by clicking back button or some other link or by closing the browser.</p>
  
  <p><img src="https://i.stack.imgur.com/0dE9o.png" alt="enter image description here"></p>
  
  <p>So please give your valuable solution how to achieve this.</p>
  
  <p>Thank you all in advance.</p>