Auto Logout closing chatwindow
Fully customizable web chat created using AJAX.
Brought to you by:
frug,
madblueimp
Is there a possibility that a user will logged out automaticaly by closing the chat window?
If you close the chat window without pushing the logout button the user still appears online in forum (as an example Chat [1] or *= User ist logged in Chat).
THX
Logged In: YES
user_id=1969086
Originator: NO
Unfortunately there is no reliable way to do this.
Even if you add an AJAX request (with a logout command) to the unload event of the chat page you cannot be sure it will be send by the browser (judging from my own tests).
And the unload event is also fired if you reload the page.
Without a permanent socket connection you cannot be sure if a user is still logged in or has been logged out.
For this reason users will be declared "logged out" if no update requests have been send for a certain amount of time (timeout).
Logged In: NO
>For this reason users will be declared "logged out" if no update requests
>have been send for a certain amount of time (timeout).
Is there still a solution over config.php?
Or can you tell me an addon do realize a user timeout (perhaps auto logut after 5Min of inactivity)?
Best regards!
Logged In: YES
user_id=1969086
Originator: NO
The inactivity timeout is set in lib/config.php:
---
// Minutes until a user is declared inactive (last status update) - the minimum is 2 minutes:
$config['inactiveTimeout'] = 2;
// Interval in minutes to check for inactive users:
$config['inactiveCheckInterval'] = 5;
---
You should know that a user can only be declared inactive if minimum one other user is online as well.
Logged In: YES
user_id=2024135
Originator: NO
>You should know that a user can only be declared inactive if minimum one
>other user is online as well.
Hm... I see *hmpf*
Any other chance?
It is unfavourably, because I think 90% will not logout by using the Button.
The result is, that mostliy one User will be diplayed online, but it isn`t.
Logged In: YES
user_id=1969086
Originator: NO
You could call the method to remove inactive users from the online list using the chat interface class.
This method can be called from a custom script, e.g. from a page on your website or using a cron-job.
---
function getChatInterface() {
static $ajaxChat;
if(!$ajaxChat) {
// URL to the chat directory:
if(!defined('AJAX_CHAT_URL')) {
define('AJAX_CHAT_URL', './chat/');
}
// Path to the chat directory:
if(!defined('AJAX_CHAT_PATH')) {
define('AJAX_CHAT_PATH', realpath(dirname($_SERVER['SCRIPT_FILENAME']).'/chat').'/');
}
// Validate the path to the chat:
if(@is_file(AJAX_CHAT_PATH.'lib/classes.php')) {
// Include Class libraries:
require_once(AJAX_CHAT_PATH.'lib/classes.php');
// Initialize the chat interface:
$ajaxChat = new CustomAJAXChatInterface();
}
}
return $ajaxChat;
}
function removeInactiveChatUsers() {
$chatInterface = getChatInterface();
if($chatInterface) {
$chatInterface->removeInactive();
}
}
---
Logged In: YES
user_id=2024135
Originator: NO
Excelent :o)
I`ve put it into a META refresh in forums index.php called from the overall_header.php (phpbb forum).
if(1)
{
$template->assign_vars(array(
"META" => '<meta http-equiv="refresh" content="120;url=' .append_sid("index.$phpEx") . '">')
);
removeInactiveChatUsers();
}
THX for help!
Logged In: YES
user_id=1050865
Originator: NO
modbo, I have the same issue here. Could you please explain what (and where) exactly you have done to "auto logout" the users who left the chat just by closing the window?
(I use ajax chat with phpBB 3.0.0)
Thanks a lot.
Logged In: NO
pls help me..
i don´t understand this..
where put it in?
lg
maik
Logged In: YES
user_id=1473741
Originator: NO
This is difficult to implement cleanly and across browsers - it may be best to allow the user to timeout for not logging out correctly.
Logged In: NO
can you help me?
greetings
maik