Server cannot modify cookies after HTTP headers have been sent
Application Type
Traditional Web
Platform Version
11.9.1 (Build 20359)

We have a simple traditional web page which contains a table records and a button (ajax submit) to refresh that table.

For this page the one requirement was that the table records would refresh itself every 1 second, without user action. So we added some javascript code with setInterval function to run every 1 second, executing a screen button click (which is visible):

var refreshInterval;

function setRefresh() { document.getElementById('" + btnRefresh.Id + "').click(); }

function startTimer() { refreshInterval = setInterval(setRefresh, 1000); }

Code itself runs without any issues, does not throw any front-end error and refreshes the table records. The problem is that after (around) 5 minutes we get an error (in Service Center error log) for every elapsed second:

Message: Error invalidating espace caches.

Stack: System.Web.HttpException (0x80004005): Server cannot modify cookies after HTTP headers have been sent.
at System.Web.HttpResponse.BeforeCookieCollectionChange()
at System.Web.HttpCookieCollection.Set(HttpCookie cookie)
at OutSystems.Application.Initialization.ASPNet.Http.ASPNetResponseCookies.InnerSet(String name, String value, CookieOptions options)
at OutSystems.Application.Core.Http.AbstractResponseCookies.Set(String name, String value, CookieOptions options)
at OutSystems.HubEdition.RuntimePlatform.NewRuntime.Authentication.LoginInfo.WriteLoginInfoToResponse(IHttpContext httpContext)
at OutSystems.HubEdition.RuntimePlatform.NewRuntime.Authentication.SSOService.ReactiveWriteCookiesToResponse()
at OutSystems.HubEdition.RuntimePlatform.HeContext.OnEndRequest()

In Service Center we can set Cache Time In Minutes value (Applications Authentication). We changed that value from 5 to 2 minutes and realized the error is thrown about 2 minutes after the page was first loaded. May this mean ajax submit does not 're-authenticate'? Anyone had this issue? Or am I missing something?

PS: Cache Time In Minutes configuration states to be only for Mobile and Reactive, and we are working on Traditional.

Rank: #72

Hi João,

It seems this is a bug related to the SSO between App Types setting that was fixed in Platform Server version 11.10.0.

We fixed the issues in SSO between app types causing "invalidating espace caches" error messages in Service Center, by improving the lifecycle of cookies involved in SSO between app types. (RTAF-3153)

We had these same errors popping up in our logs and I found this post in which Alex pointed me to bug fix report.

Hope this helps!