diff --git a/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs b/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs
index af87b8494b..a878910bf3 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/MacroRenderingController.cs
@@ -24,11 +24,6 @@ namespace Umbraco.Web.BackOffice.Controllers
///
/// API controller to deal with Macro data
///
- ///
- /// Note that this implements IRequiresSessionState which will enable HttpContext.Session - generally speaking we don't normally
- /// enable this for webapi controllers, however since this controller is used to render macro content and macros can access
- /// Session, we don't want it to throw null reference exceptions.
- ///
[PluginController(Constants.Web.Mvc.BackOfficeApiArea)]
public class MacroRenderingController : UmbracoAuthorizedJsonController
{
diff --git a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs
index 471aed51e1..3c6b538506 100644
--- a/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs
+++ b/src/Umbraco.Web.BackOffice/Extensions/BackOfficeApplicationBuilderExtensions.cs
@@ -35,6 +35,9 @@ namespace Umbraco.Extensions
app.UseImageSharp();
app.UseStaticFiles();
+ // Must be called after UseRouting and before UseEndpoints
+ app.UseSession();
+
if (!app.UmbracoCanBoot()) return app;
app.UseEndpoints(endpoints =>
diff --git a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
index adae78bd74..bc88b1360b 100644
--- a/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
+++ b/src/Umbraco.Web.Common/Extensions/UmbracoCoreServiceCollectionExtensions.cs
@@ -241,6 +241,16 @@ namespace Umbraco.Extensions
if (container is null) throw new ArgumentNullException(nameof(container));
if (entryAssembly is null) throw new ArgumentNullException(nameof(entryAssembly));
+ // Add service session
+ // This can be overwritten by the user by adding their own call to AddSession
+ // since the last call of AddSession take precedence
+ services.AddSession(options =>
+ {
+ options.Cookie.Name = "UMB_SESSION";
+ options.Cookie.HttpOnly = true;
+ options.IdleTimeout = TimeSpan.FromSeconds(60);
+ });
+
// Add supported databases
services.AddUmbracoSqlCeSupport();
services.AddUmbracoSqlServerSupport();