Fixed problem with detecting whether session is active.