title: Check if user is online for a chat app made using Firebase
body: <p>Using Real Time Database of Firebase to create a Chat App. </p>
  
  <p>The users class looks like this (default is JSON in Firebase) </p>
  
  <pre><code>"users" : {
       "-K2ib62mjHh34CAUfig" : {
        "lastvisibleat" : "2016-09-30 07:10:40",
        "name" : "Peter Parker",
        "online" : "1"
      },
      "--K2ib62mjHh34CAUh18" : {
        "lastvisibleat" : "2016-09-30 07:26:17",
        "name" : "Riddhi Dixit",
        "online" : "1"
      }
  }
  </code></pre>
  
  <p>I want to change the status from <code>online: "1"</code> to <code>online : "0"</code> when the user's internet suddenly gets unavailable or browser crashes of its own or something as such that cannot be handled with <code>sess_destroy()</code> method of CodeIgniter. </p>
  
  <p>Server is build in PHP using CodeIgniter.  </p>