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?
public void ValidateUser_LOGSTS_Update(object sender, EventArgs e)
{
int userId = 0;
string Cur_user = Session["Userid"].ToString();
String constr = ConfigurationManager.ConnectionStrings["abcd"].ConnectionString;
using (SqlConnection con = new SqlConnection(constr))
{
using (SqlCommand cmd = new SqlCommand("sp_tbl_LogCheck_update"))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@userID", Cur_user);
cmd.Parameters.Add("@msg", SqlDbType.Int, 20).Direction = ParameterDirection.Output;
cmd.Connection = con;
con.Open();
cmd.ExecuteNonQuery();
// read output value from @NewId
string msg_sts = Convert.ToString(cmd.Parameters["@msg"].Value);
con.Close();
if (msg_sts == "0")
{
Session.Clear();
Session.Abandon();
//Response.Redirect(FormsAuthentication.LoginUrl);
FormsAuthentication.RedirectToLoginPage();
}
}
}
}
<script type="text/javascript">
var t;
window.onload=resetTimer;
document.onkeypress=resetTimer;
function logout()
{
alert("You are now logged out.")
location.href = 'Login.aspx'
}
function resetTimer()
{
clearTimeout(t);
t=setTimeout(logout,60000) //logs out in 10 min
}
</script>