Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

126
Views
I want to insert logout time when close the browser using Javascript / Jquery

: i want to insert logout time in database when user close the browser. i have tried onbeforeunload in javascript and jQuery but it doesn't inserting logouttime in database .

Javascript Code :

window.onbeforeunload = function(){ 
    const empid = 47 ;
    $.ajax({
        url: "response.php",
        type: "GET",
        data: {'Empid':empid, 'LogoutTime':date()},
        success: function (response) {
            alert(Logged Out Success....);
        }
    });
}
</script>

response.php

    $Empid = $_GET['empid'];
   $logout = $_GET[''LogOutDatetime]
    $link = mysql_connect('localhost', 'root', 'root');
    mysql_select_db("DBtest");
    $delete = mysql_query("UPDATE  Table LoginTime  SET `logout_time` = "LogoutTime" WHERE 'id`= '" . $Empid .  "'");
    mysql_close();
    die();
?>

Please Help me how i insert logout time when close the browser .

about 4 years ago · Santiago Gelvez
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!