• Dev
  • Add css class to page dependent on cookie

So... I want to add a class to the body tag dependent on a cookie from a parent domain, and I'm sure there should be a super simple way to do it but it's late and my brain isn't working.

We have a site at example.com and flarum installed in a subdirectory discuss.example.com

site.com sets a cookie dependent on a user colour choice, with a value of true/false.

What I want to do is to add a .something class to body in Flarum (so that I can target elements within the page using css) if that cookie is set to true.

Any thoughts on the quickest, simplest way to do that?

    JohnP is the cookie HTTP only or not? If it's not, a solution with javascript can be used.

    If the cookie is HTTP only, then it's a bit more complex but still possible using the Flarum PHP + JS APIs together.

      a month later

      clarkwinkelmann The cookie could be either, whatever is going to make it easiest to implement this in Flarum.