added a check before updating unique_session_id since if the user tries to logout after session timeout the record will be nil