Dim user_id As String = CType(Session("user_id"), String) this one you can using if it not existing actually or you sure it within session section so you can ignor it and use this If ( Session("user_id") isNot Nothing Or Is Nothing !! easy