fix UnboundLocalError in session.py

darcs-hash:20090317083929-b2873-6111f48903aa57ec6f216993653dc69b6034d503
Added SessionStateError to session.py and used it

darcs-hash:20090317100856-58103-b7b6351f02afdf18dd8adcdd607ef6c3429a878a