How to determine if a Session Variable exists?

S

Shapper

Hello,

How to determine if a Session Variable exists?

In Page_Load I need to check is Session("MyVar") Exists.
If it doesn't exist then I created it and give it a value:
Session("myVar") = "Value"

Thanks,
Miguel
 
N

Nawaz Ijaz

Simply do this..

if ( Session("MyVar") == "" )
{
Session("MyVar") = "Your Value"
}
 
K

Kevin Spencer

Ancient Zen problem:

If a Session variable is set, and there is no class to read it, does it
consume resources?

--
;-)

Kevin Spencer
Microsoft MVP
..Net Developer
Ambiguity has a certain quality to 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

Top