Session Variables

axum

Active member
Joined
Mar 28, 2003
Messages
40
Hi, im thinking of storing a Hashtable and an ArrayList as Session Variables. When my page gets posted back these variables may be overwritten, i.e. they are populated again with different data, is there any need to delete the original variable or can use the same call and it will be overwritten....

E.g.

if (!Page.IsPostBack)
{
Session["myhash"] = hashtable;
}
else
{
Session["myhash"] = hashtable1;
}

Is this ok? or should i clear or do something with the existing Session Variable first?

Thanks,

Axum
 
cheers..

Another question, basically at the top of the page i have got a Hashtable declaration (this is what i use as my temporary ID store). When i need to use my Session["hashtable"] how should i use it....is this ok? I have got this in multiple places in my code...

Hashtable tempHash = Session["hashtable"];

while loop
{
tempHash.Add(blah,blah);
}

Session["hashtable"] = tempHash;

then in a click event i have got a very similar thing, again writing out like this:

private void fillHash()
{
tempHash = Session["hashtable"];
//add to it etc...
}

so basically i am making these declarations to tempHash all over the place. Is that ok? I guess i should close/destroy these tempHashs once i finish, how do i do that?
 
Back
Top