Aaron Aaron - 17 days ago 9
PHP Question

WordPress plugin caching issues

I'm trying to set and read cookies within WordPress across my site by way of a custom plugin that I wrote.

add_action( 'wp_head', 'my_cookie_code' );


The code that I wrote works, however, once it's deployed to our live server it does not.

I think this is because of our WordPress caching system. When I turn it off, my cookie code works but once it's on, it does not.

Without turning off my WordPress caching system, how can I get my code to work with it?

I want each page to be cached by the caching system but I still want my little bit of code to be executed.

Thanks

Answer

It appears that this is an issue with the WPEngine caching system.

When I switched my code from being PHP based to JavaScript, I was able to solve the problem that I was having.

More information on this issue can be found here: Cookies and php sessions on WPEngine

Comments