Could someone tell me how to check if a session variable exists and if
not to create it.
Thanks,
MiguelSession["abc"] will return null if abc doesn't exist.
Session["abc"] = 123 will write abc to the session even if it didn't exist
there before.
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"shapper" <mdmoura@.gmail.comwrote in message
news:1173354277.199378.128980@.j27g2000cwj.googlegr oups.com...
Quote:
Originally Posted by
Hello,
>
Could someone tell me how to check if a session variable exists and if
not to create it.
>
Thanks,
Miguel
>
if (Session["MyVar"] == null)
Session["MyVar"] = "hello";
"shapper" <mdmoura@.gmail.comwrote in message
news:1173354277.199378.128980@.j27g2000cwj.googlegr oups.com...
Quote:
Originally Posted by
Hello,
>
Could someone tell me how to check if a session variable exists and if
not to create it.
>
Thanks,
Miguel
>
0 comments:
Post a Comment