I am having table to track user online status by setting \'is_online\' field to 1. Now User get logged in the site and shut down his/her system or power down at that time he
The normal solution is to store a timestamp in the table which you update every time the user does something. Users with a recent timestamp (say, five minutes) are shown as logged in, everybody else are logged out.
It doesn't even have to be updated on every page load. Keep a timestamp in the session with the last update time as well, and only update the table when the database flag are about to expire.