How to enable PHP Sessions in Wordpress?

5

I'm developing my website using the Wordpress platform.

I needed a lot, but very much, to enable PHP Sessions inside the platform, so logged-in users can stay logged in to the subdomains I'm creating.

Any suggestions? I already tried to enable this for a plugin, but it did not work. You gave error messages in the header.

Note : The wordpress version I am using is 4.3

    
asked by anonymous 15.01.2016 / 18:44

1 answer

2

Hello try to do one of the following:

Generically in PHP, use this:

ini_set('session.cookie_domain', '.domain.tld');
if ( empty(session_id()) ) session_start();

No .htaccess:

php_value session.cookie_domain .example.com

In WordPress wp-config.php:

define('COOKIE_DOMAIN', '.domain.tld');

This session can only be shared in a single WordPress installation. That is, if you have other subdomains with another WordPress installation, this setting may not work, since WordPress has another session for another installation.

Maybe it helps:)

    
15.01.2016 / 19:38