Faisal

Faisal

  • NA
  • 73
  • 1.7k

How to set user status β€œ0” when automatically logout user?

Oct 16 2019 7:36 AM
I'm using javascript in aspx page to log-out inactive user. But also i need to change user status "0" when logged-out automatically. How can i send the value user status "0" when inactive user will logged-out automatically?
 
  1. public void ValidateUser_LOGSTS_Update(object sender, EventArgs e)  
  2.     {  
  3.         int userId = 0;  
  4.   
  5.         string Cur_user = Session["Userid"].ToString();  
  6.         String constr = ConfigurationManager.ConnectionStrings["abcd"].ConnectionString;  
  7.         using (SqlConnection con = new SqlConnection(constr))  
  8.         {  
  9.             using (SqlCommand cmd = new SqlCommand("sp_tbl_LogCheck_update"))  
  10.             {  
  11.                 cmd.CommandType = CommandType.StoredProcedure;  
  12.                 cmd.Parameters.AddWithValue("@userID", Cur_user);  
  13.                 cmd.Parameters.Add("@msg", SqlDbType.Int, 20).Direction = ParameterDirection.Output;  
  14.                 cmd.Connection = con;  
  15.                 con.Open();  
  16.                 cmd.ExecuteNonQuery();  
  17.   
  18.                 // read output value from @NewId  
  19.                 string msg_sts = Convert.ToString(cmd.Parameters["@msg"].Value);  
  20.   
  21.                 con.Close();  
  22.                 if (msg_sts == "0")  
  23.                 {  
  24.                     Session.Clear();  
  25.                     Session.Abandon();  
  26.                     //Response.Redirect(FormsAuthentication.LoginUrl);  
  27.                     FormsAuthentication.RedirectToLoginPage();  
  28.                 }  
  29.   
  30.   
  31.             }  
  32.   
  33.         }  
  34.   
  35.     }  
  36.      
 
  1. <script type="text/javascript">  
  2.   
  3.     var t;  
  4.     window.onload=resetTimer;  
  5.     document.onkeypress=resetTimer;  
  6.   
  7.     function logout()  
  8.     {  
  9.         alert("You are now logged out.")  
  10.         location.href = 'LogOut.aspx'  
  11.     }  
  12.     function resetTimer()  
  13.     {  
  14.         clearTimeout(t);  
  15.         t=setTimeout(logout,60000) //logs out in 10 min  
  16.     }  
  17.   
  18.     </script> 

Answers (1)