Session.clear ans session.abandon
-
Sonia Gupta wrote:
Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Abandon(); leaves the session["Sonia"] AND Session["Sonia"] AS IT IS. Is this what u mean to say.
This is correct. Once you leave the scope of the request, Session["Sonia"] and Session["Sonia1"] will be removed, but until then you can still access these variables.
Deja View - the feeling that you've seen this post before.
but the fucntion session.clear() clears the session values not the session key. here session.clear() clears the session key as well, y this is happening
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
i am using the following code Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Clear(); it renders the Session["Sonia"] and session["Sonia1"] to null. Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Abandon(); leaves the session["Sonia"] AND Session["Sonia"] AS IT IS. Is this what u mean to say.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Sonia Gupta wrote:
i am using the following code Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Clear(); it renders the Session["Sonia"] and session["Sonia1"] to null.
Actually, it removed the items. If it would just set the items to null, the Session.Count property would still return 2, but clearing the session items makes it return 0.
Sonia Gupta wrote:
Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Abandon(); leaves the session["Sonia"] AND Session["Sonia"] AS IT IS.
Yes. The current session can't be removed until the current request is completed. That would be sawing off the branch you are sitting on.
--- single minded; short sighted; long gone;
-
but the fucntion session.clear() clears the session values not the session key. here session.clear() clears the session key as well, y this is happening
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Sonia Gupta wrote:
but the fucntion session.clear() clears the session values not the session key.
No, it doesn't clear the values, it removes the items.
Sonia Gupta wrote:
here session.clear() clears the session key as well, y this is happening
The Session.Keys collection is a collection of the names in the Session.Items collection. As Session.Clear removes all the items in Session.Items, the Session.Keys collection also becomes empty.
--- single minded; short sighted; long gone;
-
Sonia Gupta wrote:
i am using the following code Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Clear(); it renders the Session["Sonia"] and session["Sonia1"] to null.
Actually, it removed the items. If it would just set the items to null, the Session.Count property would still return 2, but clearing the session items makes it return 0.
Sonia Gupta wrote:
Session["Sonia"] = "11"; Session["Sonia1"] = "12"; Session.Abandon(); leaves the session["Sonia"] AND Session["Sonia"] AS IT IS.
Yes. The current session can't be removed until the current request is completed. That would be sawing off the branch you are sitting on.
--- single minded; short sighted; long gone;
Guffa wrote:
can't be removed until the current request is completed
What's the meaning of this line. if u provide an example.
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
Sonia Gupta wrote:
but the fucntion session.clear() clears the session values not the session key.
No, it doesn't clear the values, it removes the items.
Sonia Gupta wrote:
here session.clear() clears the session key as well, y this is happening
The Session.Keys collection is a collection of the names in the Session.Items collection. As Session.Clear removes all the items in Session.Items, the Session.Keys collection also becomes empty.
--- single minded; short sighted; long gone;
one thing i wanted to make clarification about is that session.abandon() does not remove the key or the value until we navigate to another page.Once the use navigates to another page , both the key and the value gets removed. and as far as the removing of session key and value is concerned , session.clear() method is sufficient , according to my understanding . Then What's the need of session.abandon()?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
one thing i wanted to make clarification about is that session.abandon() does not remove the key or the value until we navigate to another page.Once the use navigates to another page , both the key and the value gets removed. and as far as the removing of session key and value is concerned , session.clear() method is sufficient , according to my understanding . Then What's the need of session.abandon()?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Suppose that you want to continue working with the session in the context of the page, but you want the session to be cleared when you leave the page. If your page hosts another page in an iframe, then the inner page also has access to the session variable. This means that you can abandon the variable in the Page_Load, and still access it in the inner page.
Deja View - the feeling that you've seen this post before.
-
Suppose that you want to continue working with the session in the context of the page, but you want the session to be cleared when you leave the page. If your page hosts another page in an iframe, then the inner page also has access to the session variable. This means that you can abandon the variable in the Page_Load, and still access it in the inner page.
Deja View - the feeling that you've seen this post before.
session.abandon removes the key and the value. right?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
-
session.abandon removes the key and the value. right?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Eventually yes.
Deja View - the feeling that you've seen this post before.
-
Eventually yes.
Deja View - the feeling that you've seen this post before.
in, Session.Clear() Session key also remove. coz.. foreach (string ste in Session.Keys) { Response.Write(ste + ":" + Session[ste]); Response.Write("
"); } O/p is nothing.Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
-
session.abandon removes the key and the value. right?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
in, Session.Clear() Session key also remove. coz.. foreach (string ste in Session.Keys) { Response.Write(ste + ":" + Session[ste]); Response.Write("
"); } O/p is nothing.Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
-
in, Session.Clear() Session key also remove. coz.. foreach (string ste in Session.Keys) { Response.Write(ste + ":" + Session[ste]); Response.Write("
"); } O/p is nothing.Never Think That You Have Failed Instead Always Think That u hav Better Chance Next Time...
What does this have to do with Session.Abandon removing the keys?
Deja View - the feeling that you've seen this post before.
-
session.abandon removes the key and the value. right?
Sonia Gupta Soniagupta1@yahoo.co.in Yahoo messengerId-soniagupta1 Love is Friendship and Friendship is Love....
Sonia Gupta wrote:
session.abandon removes the key and the value. right?
No, it doesn't. It marks the Session object for removal. When the request finishes, the entire Session object is removed. The items are never removed from the Session object.
--- single minded; short sighted; long gone;