0

Default1.aspx

protected void Button1_Click1(object sender, EventArgs e)
    {
        Session["name"] = TextBox1.Text;
        Response.Redirect("Default2.aspx");
    }

Default2.aspx

protected void Page_Load(object sender, EventArgs e)
    {

        string sBeforeAbandon;
        string sAfterAbandon;

        sBeforeAbandon = Session["name"].ToString ();
        Session.Abandon();
        if (Session["name"] != null)
        {
            sAfterAbandon = Session["name"].ToString();
        }

Hey frnds Session.Abandon clears all the session on the next page,If i access suppose this session value in Defaul3.aspx,then session value is not retrieved..But i also want that in sAfterAbandon value cannot be access,Which statement i have to write above this statement,so dat i m not able to access d session??

Secondly tell me dat is there any method Session.kill() in ASP.net????

2
Contributors
1
Reply
2
Views
8 Years
Discussion Span
Last Post by sknake
0

Session.Abandon() is what you are looking for. You cant very well throw an error if the session has been abandoned because you don't have a place to store if it has been abandoned since you're clearing the session. Likewise when a client requests a new page it will start a new session -- how should the webserver know if the session is a new session from a new browser window, or a new request from an existing browser window?

Are you trying to figure out how to keep users logged in -- and if you abandon the session have it log them out and redirect them to a certain area?

[edit]Actually you can Call Response.Flush() and an exception will throw if you try to access the session state after the response has been sent[/edit]

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.