session clearing and error handling for expired session among other things