Handle session expiry

This code is needed by the corresponding monitor pull-request.