Wordpress - How to fake a Wordpress login?

You could create a dummy user (with no rights) and log in every visitor using this dummy user. This could be done pretty easily:

wp_set_auth_cookie($uid, true);
wp_set_current_user($uid);

But in my opinion that's a rather flawy workaround.

Your main problem is that all pages for not-logged-in users come from the page-cache. That also means that all users get the same html output as long as there is page-caching active. So there can't be any difference to your pages based on the visitor. All visitors get the same output.

A better way would be to create a ticket at WPEngine and ask them to disable page-caching for your site. That's actually also the way they suggest on the page you linked to.


A quick and hacky solution is to put this in your header include file:

<?php
  // Re-enable sessions for WPEngine
  setcookie('wordpress_logged_in_' . md5("test"), md5("random"), time()+3600);
?>

It's wrong, but it works.