Using session in WP without trouble with the API REST
I build a custom plugin that make me able to use SESSION to passe parameters from a page to others pages without GET parameters.
This works very well.
Basically i start my session like this :
add_action('init', 'myStartSession', 1);
function myStartSession() {
if (session_status() == PHP_SESSION_NONE) {
session_start();
}
}
And then set session variable like this in different part of the site
$_SESSION['key'] = value;
And finish like this
add_action('wp_logout', 'myEndSession');
function myEndSession() {
session_destroy();
}
Problem : If i go on Tools Health Site, i have 2 errors :
- An active PHP session was detected
- API REST Error : cURL error 28: Operation timed out after 10001 milliseconds with 0 bytes received (http_request_failed)
If i comment my start session line i don't have the 2 errors more. But i need this session. How can i make it different ?