Welcome Guest, Not a member yet? Register   Sign In
Updating Database on Browser Exit Close..
#1

[eluser]ginteno[/eluser]
Hi,

I want to update my member log status.. from online to offline everytime the browser is being close or shutdown.
how do i do it???

I want to call this function everytime the browser is being closed..

public function set_status($status){
$data = array('status' => $status);
$this->db->where('username', $this->session->userdata('username'));
$this->db->update('members',$data);
}

any help will be appreciated..
#2

[eluser]jonez[/eluser]
You can't, not all browsers support onunload AJAX calls. Another way to show status is to track actions, each time a user performs an action stamp it in a tracking DB. Check for stamps within the last 5m to see who was online recently.
#3

[eluser]ginteno[/eluser]
Wow this is a huge help.. thank you so much...
#4

[eluser]ginteno[/eluser]
about the last_activity... correct me if im wrong, i was thinking of this formula to know who were recently online..

it's

if ( Time_Now > Last_activity_time + 5min ){
echo "Offline";
}
else{
echo "Online";
}

if this is right.. can you tell me what's the codeigniter syntax for the condition above..
Thank you!..




Theme © iAndrew 2016 - Forum software by © MyBB