Check "data.query" exists

Check "data.query" exists before checking the data.query.session_id.
Avoid: "TypeError: Cannot read property 'session_id' of undefined "