Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837749
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:48:25+00:00 2026-06-14T09:48:25+00:00

In my chat application i am having the logout button and it works fine.

  • 0

In my chat application i am having the logout button and it works fine.

Now I need to logout the application when I closed the browser window also..How can I achieve this…

Thanks in advance…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:48:26+00:00Added an answer on June 14, 2026 at 9:48 am

    Add your logout code to the on onunload event.

    window.onunload = function () {
        //logout code here...
    }
    

    In JQuery you can use the .unload() function. Remember that you don’t have much time so you may send the Ajax request but the result may not reach the client.

    Another trick is to open a small new window and handle the logout there.

    window.open("logout url","log out","height=10,width=10,location=no,menubar=no,status=no,titlebar=no,toolbar=no",true);
    

    If you want to disable closing the window (or at least warn the user), you can use this code:

    window.onbeforeunload = function(event) {
        //if you return anything but null, it will warn the user.
        //optionally you can return a string which most browsers show to the user as the warning message.
        return true;
    }
    

    Another trick is to keep pinging the client every few seconds. If no reply comes back, assume the user has closed the window, browser has crashed or there is a network issue that ended the chat session anyway. On the client side, if you don’t receive this ping package, you can assume that network connection or server has a problem and you can show the logout warning (and optionally let the user login again).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

A chat application can be implemented using a database (browser send a request conterminously
I'm making a chat application that works with long-polling to emulate a push from
Well, lets say I'm building ActiveMQ based chat application. It's pretty simple. Having only
I am having trouble getting my chat application working correctly. I have 2 textbox's,
I'm trying to create a chat application with jQuery without having to using setTimeout
I have recently started having a need to start learning Java Script. My application
I am developing a chat application. And i want to have pop up window
as I am doing a small chat application in vb.net (windows form), I'm having
I want to make chat application and for the first step, I need to
I'm creating a chat application and I need a little bit of guidance. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.