0

I have this code

protected void loginbutton_Click(object sender, EventArgs e)
    {
        Int32 d = checkuser(uid.Text, pwd.Text);
        if (d == -1)
        {
            prompt.Visible = true;
            prompt.Text = "Unregistered ID. Please make sure that you have a registered account and you have correctly typed in the user ID";
        }
        else if (d == 1)
        {
            Server.Transfer("Enrollment.aspx");
        }
        else if (d == -2)
        {
            prompt.Visible = true;
            prompt.Text = "Incorrect password. Please try again.";
        }
    }

    private Int32 checkuser(string u, string p)
    {
        SqlCommand cmd = new SqlCommand();
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.CommandText = "usp_checkuser";
        cmd.Connection = con;
        cmd.Parameters.Add("@uid", SqlDbType.NVarChar).Value = uid.Text;
        cmd.Parameters.Add("@pwd", SqlDbType.NVarChar).Value = pwd.Text;
        SqlParameter p1 = new SqlParameter("@ret", SqlDbType.Int);
        p1.Direction = ParameterDirection.ReturnValue;
        cmd.Parameters.Add(p1);
        con.Open();
        cmd.ExecuteNonQuery();
        Int32 k = Convert.ToInt32(cmd.Parameters["@ret"].Value);
        return k;
    }

for transferring the user to the desired page when he/she login. What I need to do is the logout. The user must not be able to go back to the previous page when he/she choose to logout.

3
Contributors
4
Replies
5
Views
6 Years
Discussion Span
Last Post by dnanetwork
0

Hi,
One method-create a session variable and store the userid and check it exist on page load event of every page.On logout click, clear the session variable and redirect to login page.
Hope your reply

0

Hi,
Assign:-
Session["uid"]=str_uid;
Retrieve:-
string id=Session["uid"].ToString();
Checking:-
if(Session["uid"]!=Null)
{
}
hope ur reply

0

clear all the session variables
and simply disable the cache of the page

you can do this using code or in the markup.
or you can use server.transfer

hope that helps

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.