Vishwas Kadamannaya

Vishwas Kadamannaya

  • 1.6k
  • 122
  • 142.5k

Check for Session in Asp.Net

Dec 2 2013 5:13 AM
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)