When troubleshooting a problem on a site that’s new to you, what do you do first? Start tracing code? Or search Google? In this situation, I’d think you need to start tracing code to first understand the underlying technology. But maybe not always.
I was working on a WordPress site that’s supposed to remember a selection you make from a pull down menu. In this case, a store location. From that point on, it should remember the selected location anytime you view the site and show you interesting things about it. And if, in the future, you select a different location, it should remember that one instead. Simple enough. The problem was that it only worked if you were logged into the WordPress admin. It didn’t cause an error if you weren’t, it just didn’t do anything at all.
My first instinct was that a plugin or a chunk of custom PHP was set so that it’s only functional if you’re logged in — a useful thing in many situations. But when tracing the code, I found typical cookie-based routines that, by all indications, should be working fine. The cookie was being saved in the browser, but still the site was not able to read it unless you were logged in.
This is one of those times where I should’ve searched Google first, because that’s where I found the answer.
Apparently you need to have a cookie exclusion configured with WPEngine’s caching, even if you have object caching turned off. I checked with Brandi at WPEngine support and she was nice enough to set it up for me. The site started working immediately. I wondered if this was something we could manage on our own, but she indicated that cookie exclusions need to be configured using a support request.
Speaking of which, I recently noticed that WPEngine will be deprecating .htaccess files in PHP 7.4, the version that new environments currently use by default. When setting up common .htaccess directives, these will now also require a support request. I hope WPEngine makes these things more configurable going forward.