AID-507 Added session validity check from upstream.