In certain cases, you might come across the issue that after you’ve switched the website to SSL: it immediately logs you out, every time the page is reloaded. Most of the times, the cause of this issue is that somewhere in the code the domain is still being forced to the http:// domain. In the most recent case that we came across, the user had the following code in their theme’s functions.php file:
update_option( 'siteurl', 'http://domain.com' ); update_option( 'home', 'http://domain.com' );
As a result of this, the site was forced back to http:// on every page load. Because WordPress keeps you logged in on a specific domain, and an https:// URL is considered to be a different domain, this results in you being logged out: as your log-in cookies are not valid anymore for the site’s domain. The solution is simple: just remove those lines! They were probably put there to quickly change the domain. It’s also possible that the http:// domain is set in the wp-config.php file (instead of the active theme’s functions.php file), with the following lines of code:
define(
'WP_HOME'
,
'http://example.com'
);
define(
'WP_SITEURL'
,
'http://example.com'
);