Ensure session is set before writing timeout interval (#13617)

Change-Id: I4a4f85fe400b9d6e60b81fd5c6c8dbc3b3eac02c