need help for creating session in asp.net

i have made 2 pages....1 for login n next to show after successful login....
on login page i have created a button....in its handler i have created session.... on the load event of next page i m checking for the availibity of the session variable n its value.... its workin well..... but the problem comes when i press back button of the browser.....after signing out when i press back button the page is being displayed.....(this should not happend).... can anyone help me regarding this...?? plz reply soon....

Replies

  • Mahesh Dahale
    Mahesh Dahale
    adding following code in the page load of the page for which we do not want to cache the page in history.

    [COLOR=black][COLOR=black][FONT=Arial][COLOR=black][COLOR=black][FONT=Arial][COLOR=black][COLOR=black][FONT=Arial][COLOR=black][COLOR=black][FONT=Arial][COLOR=black][FONT=Arial][COLOR=black][FONT=Arial][COLOR=black][FONT=Arial][FONT=Times New Roman][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial][FONT=Arial]Response.Buffer=true;
    Response.ExpiresAbsolute=DateTime.Now.AddDays(-1d);
    Response.Expires =-1500;
    Response.CacheControl = "no-cache";
     if(Session["SessionId"] == null)
        {
        Response.Redirect ("WdetLogin.aspx");
        }
    }[/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/FONT][/COLOR][/COLOR][/FONT][/COLOR][/COLOR][/FONT][/COLOR][/COLOR][/FONT][/COLOR][/COLOR]
    Or

    Response.CacheControl = "no-cache";
    for session details
    ASP Session object
  • Mahesh Dahale
    Mahesh Dahale
    when logging out you should use
    Session.Abandon();
    Session.Redirect("Login.aspx");
    
    instead of Session["loggedIn"] = false;
  • Hima Kapadia
    Hima Kapadia
    haha.... have u tried this code.?? this doesnt work in mozilla.... it only works in IE...
  • Mahesh Dahale
    Mahesh Dahale
    ok
    Try this java script
  • gsxraddict
    gsxraddict
    Here, I want you to watch this:

    #-Link-Snipped-#

    Membership roles are a good .net option.
  • sarveshgupta
    sarveshgupta
    protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["CS"] != null)
            {
                con.ConnectionString = Session["CS"].ToString();
                com.Connection = con;
                Session.Add("User_Name", null);
                Session.Add("Password", null);
            }
            else
            {
                Response.Redirect("Main Home.aspx");
            }
    
        }
    This will be for the page users visits after looging in

    and on the click of Sign out

      protected void logout_Click(object sender, ImageClickEventArgs e)
        {
            Session["User_Name"] = null;
            Session["Password"] = null;
            Response.Redirect("Default.aspx");
        }
    
    This will help you solve the problem.
    Am I right?
  • KurtFanta
    KurtFanta
    The following link may be of help to you: #-Link-Snipped-#

You are reading an archived discussion.

Related Posts

I would like to done the FYP (final year project) in my education. Then i think to do that the topic above. In my collage having more CNC machine and...
Here's 3 idiots trailer [official] [youtube]xvszmNXdM4w[/youtube] 3 idiots is one of the most awaited movies of 2009. Especially the engineering crowd is eagerly waiting for this movie to release. Its...
Yahoo messenger 10 beta is now currently available for download at: Yahoo! Messenger 10 Beta Can anyone post a review?
hello friends, i am interested in learning Red hat Linux and also i want to get certification in it.. I want to how much does it costs to get certification...
i want to plug in sound for my PS3 to a pioneer vsx-509s with a audio component (i think that is the name) cable the one that has 2 for...