Cookies are being cached, how to prevent it?

Okay so, today I added cookies to my website to change the language of the content displayed.
On my localhost it works fine, so I thought it would be because of Cloudflare caching.

I am setting the cookie with normal PHP: setcookie();.
Then I use the header header("Location: /") to redirect to the main page again, when checking the Cookies afterwards, I have no Cookies at all, and when I hit CTRL+R, there are the old Cookies again (without language changed).

I tried to add the Cache Level: Bypass page rule because it doesn’t change anything.

Any possible solutions?

After adding a Cache-Level: Bypass page rule for the page when I set the new language, I get the new cookies after being redirected. (I need to hit CTRL+R to see new text.) When I set the language to all languages and then try to change to a random language, the new cookies doesn’t get set and I keep the current language.

Fixed by using sessions instead of cookies.

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