By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

How to determine if a Session Variable exists?

P: n/a
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

Nov 19 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
If variable doesn't exist then its null. Simlpy.

Ziemowit

Nov 19 '05 #2

P: n/a
Simply do this..

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

Nov 19 '05 #3

P: n/a
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.

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:Oh*************@TK2MSFTNGP14.phx.gbl...
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

Nov 19 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.