Redirection after login does not work when cache activated

What we are trying to achieve is an improvement to our TTFB. In that regards, we decided to cache our public pages.
We have a modal for register/sign in on the site and the login process itself is done through an ajax call.
The php back end handle the session/cookie creation on successful login and there is a json response at the end of the pack end process. The json response contains the referrer url and we are using reload(true) if the url does not contain # otherwise its a location.window.href for redirection/reload.

So for our cache test on cloudflare, we are bypassing the cache if our login cookie is present. We set up the rule on a single page for now.

Now to the issue at hand. We activated the cache on cloudflare and upon login, the redirection happens, but the login cookie is as if not taken into account and the page remains not logged. But if we refresh the page again, then the cookie is taken into account and the page is loaded with the user logged in.

Has anyone experience this issue before when activating the cache on cloudflare please? Any setting we might have missed? Please advice. Any help would be greatly appreciated.

Thank you

This sounds like a Business or Enterprise plan with the “Bypass cache on cookie” page rule.

It just feels like because of the ajax call on a cached page, the redirect doesn’t include the cookie.

I’m not a cookie expert, or ajax calls, but it sounds like the browser doesn’t send the cookie during that automatic reload.

Thank you @sdayman
That was our assumption too, that the cookie is not being sent, but everything we tried in terms of getting the hearders/cookies sent has not been successful so far.

If anyone had this issue, it will be great to hear from them or anyone with a solution to this issue would be fantastic.

Thank you,

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.