In order to support compositors running as systemd user units without display manager, a mechanism for specifying session ID exactly must exist. Checking for `XDG_SESSION_ID` mimics loginctl behaviour e95be7def2/src/login/loginctl.c (L856).
e95be7def2/src/login/loginctl.c (L856)