hi..
i need code for login and logout where session should be timeout after some time..
and
if someone copied url and used that to log in then it redirect to main page it should not work with out prior username and pwd..
thank you..
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Pankaj PandeyRank #642 · 3.7K reputationPosted May 26, 2013, 10:23 PM EDT
try to get solution from here
http://www.c-sharpcorner.com/Blogs/11706/user-management-with-help-of-session-in-three-steps.aspx
Rohit Kapdi19 reputationPosted May 25, 2013, 12:35 AM EDT
i can help u with this but i want to know how far have u tried it by urself regarding login or logout.
sagar patil48 reputationPosted May 25, 2013, 4:38 AM EDT
Rohit Kapdi19 reputationPosted May 26, 2013, 8:43 PM EDT
sagar patil48 reputationPosted May 26, 2013, 9:11 PM EDT
public string GetConnectionString()
{
return System.Configuration.ConfigurationManager.ConnectionStrings["ConnectionString1"].ConnectionString;
}
protected void Login_Click(object sender, EventArgs e)
{
SqlDataSource sds = new SqlDataSource();
sds.ConnectionString = ConfigurationManager.ConnectionStrings["ConnectionString1"].ToString();
sds.SelectParameters.Add("Username", TypeCode.String, this.Username.Text);
sds.SelectParameters.Add("Password", TypeCode.String, this.Password.Text);
sds.SelectCommand = "SELECT * FROM [LogIn] WHERE [Username] = @Username AND [Password] = @Password";
DataView dv = (DataView)sds.Select(DataSourceSelectArguments.Empty);
if (dv.Count == 0)
{
this.Labelinfo.ForeColor = System.Drawing.Color.Red;
this.Labelinfo.Text = "Invalid username and password!";
return;
}
else
{
this.Session["Username"] = dv[0].Row["Username"].ToString();
Response.Redirect("admin/Default.aspx");
Username.Text = "";
Password.Text = "";
Labelinfo.Text = "";
}
}
logout.aspx.cs code
using above code its redirecting to back page without authentication...
so Please Help ...
Thanks for valuable reply