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.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Pankaj PandeyPosted May 27, 2013, 2:23 AM
try to get solution from here
http://www.c-sharpcorner.com/Blogs/11706/user-management-with-help-of-session-in-three-steps.aspx
sagar patilPosted May 27, 2013, 1:11 AM
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
Rohit KapdiPosted May 27, 2013, 12:43 AM
sagar patilPosted May 25, 2013, 8:38 AM
Rohit KapdiPosted May 25, 2013, 4:35 AM
i can help u with this but i want to know how far have u tried it by urself regarding login or logout.