Menu

#8 Auto Logout closing chatwindow

open
nobody
None
5
2008-04-03
2008-03-01
Anonymous
No

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

Discussion

  • Sebastian Tschan

    • status: open --> closed
     
  • Sebastian Tschan

    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).

     
  • Nobody/Anonymous

    • status: closed --> open
     
  • Nobody/Anonymous

    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!

     
  • Sebastian Tschan

    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.

     
  • Sebastian Tschan

    • status: open --> closed
     
  • modbo

    modbo - 2008-03-01

    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.

     
  • modbo

    modbo - 2008-03-01
    • status: closed --> open
     
  • Sebastian Tschan

    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();
    }
    }
    ---

     
  • modbo

    modbo - 2008-03-01

    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!

     
  • Sebastian Tschan

    • status: open --> closed
     
  • Martin Brodbeck

    Martin Brodbeck - 2008-04-03

    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.

     
  • Martin Brodbeck

    Martin Brodbeck - 2008-04-03
    • status: closed --> open
     
  • Nobody/Anonymous

    Logged In: NO

    pls help me..
    i don´t understand this..
    where put it in?
    lg
    maik

     
  • Eric Martindale

    Eric Martindale - 2008-04-28

    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.

     
  • Nobody/Anonymous

    Logged In: NO

    can you help me?
    greetings
    maik

     
Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.