Destroying Sessions

V

Varangian

Hi there,

I was testing with sessions lately and wanted to destroy a particular
session.

If I have two sessions at the same page being used.
Session["Test1"] = "testing1";
Session["Test2"] = "testing2";

on using the Session.Abandon(); .... which one of them is destroyed
the Test1 or Test2 ?
 
R

Ray Booysen

Varangian said:
Hi there,

I was testing with sessions lately and wanted to destroy a particular
session.

If I have two sessions at the same page being used.
Session["Test1"] = "testing1";
Session["Test2"] = "testing2";

on using the Session.Abandon(); .... which one of them is destroyed
the Test1 or Test2 ?
What you are doing in the first two lines is assigning the text to
Session variables not different sessions.

Calling Session.Abandon destroys the entire Session object which holds
all of your session variables.
 
R

Ray Booysen

Varangian said:
not different Sessions ?!?


how to set a different session then?
You can't. Why would you need a seperate session? You have access to
the Session object which allows you to store an "infinite" amount of
objects inside.
 
V

Varangian

but I need to destroy one of them .. Session.Remove("Test2") for
example will do ?
 
J

Juan T. Llibre

Varangian,

you are confusing "a different session" with "a different session variable".

What you want is not a different session.
What you want is a different session variable.

After you set Session.Remove("Test2"),
Session.Remove("Test2") will work fine to clear it.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,902
Latest member
Elena68X5

Latest Threads

Top