better error handling when things go wrong starting a session

http://manage.dimagi.com/default.asp?107561