According to this idea here: https://community.sdl.com/ideas/sdl-tridion-dx-ideas/i/sdl-tridion-sites-ideas/proper-mechanism-for-easily-detecting-xpm-mode-in-dxa---server-side DXA 2.2 has a


property and it should determine if the request came from XPM. I took a peek at the DXA 2.2 source and the property uses the preview-session-token cookie and the x-preview-session-token header.

The cookies set when launching XPM are the following:

enter image description here

When using the preview feature(as in the Update Preview button) the cookies are: enter image description here

So as you can see, the cookie is not set when starting XPM and therefore cannot be used to determine if XPM is active. Note that this is Tridion 9 and DXA 2.1.

My questions are:
1. Is my assumption right? Am I missing something?
2. Can the cookie be configured to appear at XPM launch time? If yes, where?
3. Has this behavior changed in Tridion 9.1?

  • you can create a custom cookie at client side detecting if page is rendered in XPM iframe.
    – Rajesh G
    Dec 19, 2019 at 2:17
  • Yeah, but unfortunately this is too late as we need this information server side.
    – Atila Sos
    Dec 20, 2019 at 16:10

1 Answer 1

  1. Your assumption is correct. The preview token is only set after Update Preview is clicked. It's always been this way.
  2. Not this cookie no. It's set by the XPM client when it retrieves a result back from the Update Preview call
  3. Not that I am aware of.

Note that Session Preview != XPM. It's a subset feature of XPM, so the IsSessionPreview property is behaving correctly as far as I know as it should work when XPM is requesting the actual session content.

If you need to know whether you're in XPM, Rajesh's solution can work. You can also check references or other headers to see if the page request came from XPM.

  • 1
    Thanks for clearing it out for me. The iframe solution is client side and it's not exactly what I'm looking for. The referer header is present when closing XPM, so that's not good too. As for other request headers, I am not sure if there is any usable for this purpose. Dec 19, 2019 at 12:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.