4
Answers

Check for Session in Asp.Net

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)