I have to implemente a simple jquery chat in a project I’m working on, and I can’t figure how I could check if a determined user has an active session, this is, is logged in (and active).
The problem with this approach in my situation is that I need to keep track if the user has an opened window.
The chat script I’m using sends a ajax request to check messages, so I better will use this and check if the user is active every, let’s say, every minute.
First, I will create a table like this:
CREATE TABLE `chat_status` (
`id` INT NOT NULL AUTO_INCREMENT,
`user_id` INT(11) NOT NULL,
`last_time_active` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`))
ENGINE = InnoDB DEFAULT CHARACTER SET = utf8 COLLATE = utf8_unicode_ci;
And then, with ajax, I will update the timestamp while the user has an opened window.
okay it is also good idea to separate the status. u used table name "chat_status" so i thought it should cover only chat data status not user logged status.