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 8684721
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T22:22:36+00:00 2026-06-12T22:22:36+00:00

I have already build a chat script for my client’s site. Once the user

  • 0

I have already build a chat script for my client’s site. Once the user gets logged in I set a session and also update a table in a database by setting chat status as 1. Once the user gets logged out, I set the chat status to 0, furthermore if the user closes the tab of the browser the chat status is set to be 0 and no more chatting takes place.

The main issue here is how to detect that the user is not available for chat if the computer of the user gets shut down or the power gets cut off. Or even if the user opens a new tab and instead of closing the tab he closes the browser?

I am stuck. Thank you 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-12T22:22:37+00:00Added an answer on June 12, 2026 at 10:22 pm

    More or less what jhonraymos had said. If this is a PHP-based chat, then you can’t really tell something like when the connection was forcefully closed easily. Simply have some sort of method to have a timeout for the chat, I would say.

    IE: If there are no requests from the client for a few minutes, or maybe as long as a few hours, then it’s safe to assume they are no longer connected, and then you can set the chat status as 0.

    Update:

    Apologies, I hadn’t seen your new comment. Looking at another page…

    session_start();
    // set timeout period in seconds
    $inactive = 600;
    // check to see if $_SESSION['timeout'] is set
    if(isset($_SESSION['timeout']) ) {
        $session_life = time() - $_SESSION['timeout'];
        if($session_life > $inactive)
        { session_destroy(); header("Location: logoutpage.php"); }
    }
    $_SESSION['timeout'] = time();
    

    Apologies again, still getting used to stackoverflow.

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

Sidebar

Related Questions

I have problem developing with live555. I already build the lib-files and example projects
We already have the database with real data inside. Now we want to build
I have already built a site from scratch. It has banning, PM, comments, etc.
I have already tried multiple ways. defaults write com.apple.Xcode PBXCustomTemplateMacroDefinitions '{ORGANIZATIONNAME=YourNameHere;}' Also i've tried
I wanna build my own chat client using xmpp on android to chat with
So I have a website already set up, and I need a comet server
I have to build a feature in my application which allows user to send
We already have build scripts that creates our web application folders very nicely. We
I'm working in a project that already have a build process running with maven
I have problem with sort array of arrays. I already build method to sort

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.