I have a login page which works fine. I would like your help for how can i do the Logout. I send you the CustomerLogin.cs class whic I created. The login1 which i have is a call to my web service. Can anyone tell me what to do?
public partial class CustomerLogin : System.Web.UI.Page
{
protected login1.login CustomerLog;
public CustomerLogin()
{
Page.Init += new System.EventHandler(Page_Init);
}
private void Page_Load(object sender, System.EventArgs e)
{
if (Session["userId"] != null)
{
Server.Transfer("FirstPage.aspx");
}
}
private void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
}
#region Web Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.submitCusLogin.Click += new System.EventHandler(this.submitCusLogin_Click);
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
private void submitCusLogin_Click(object sender, System.EventArgs e)
{
string customerEmail;
string customerPassword;
customerEmail = txtEmail.Text;
customerPassword = txtPassword.Text;
//Make a call to the Web Service Login
CustomerLog = new login1.login();
//Access the Web method Customer_Details
string getId = CustomerLog.Customer_Details(customerEmail, customerPassword);
//Return a value.Check the value of the variable resultId and
//either grant the customer access or return an error message.
if (getId == "-1")
{
loginLabel.Text = "Invalid Login please re-enter your password and email!";
}
else
{
loginLabel.Text = "Welcome";
Session["userId"] = int.Parse(getId);
Server.Transfer((string)Session["return2Page"]);
}
}
}
try to remove Session[“userId”] by using
Session.Remove("userId")and redirect to log in page, i’m not sure on login method what you are doing. if you change login status on that method you need to reset that again on the log out method.