4
Reply

Check for Session in Asp.Net

Vishwas Kadamannaya

Vishwas Kadamannaya

Dec 2 2013 5:13 AM
956
Hi All, 
        May be this is a silly Question, How to check These two conditions , 

        1.The session is not expired but , the session variable is not assigned any value.
        2. Session variable is assigned with value, but session is expired.

        if(Session["mykey"] != null)
       {
        // Session is not expired
        }
        else
       {
          // Session is expired
        }

    Will this condition work for above two scenarios, or do i have to handle this both differently.

Please Help.    



Answers (4)