You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@PetteriSeoka WordPress does not use PHP sessions. It looks like you want to start the session yourself here. The tricky part is that the PHP sessions need to send a few HTTP headers, and if the website has already pushed content out and has sent the headers, it just is not going to work. In other words, there isn't really a way to start the session late into the script loading, and instead, you got to do it really early, like for example on top of your plugin, like this:
if (PHP_SESSION_ACTIVE !== session_status())
{
session_start();
}
One important takeaway with the default PHP sessions is that they are file-based. That works on with small sites hosted on just one machine. If you are using a multi-server setup like a web farm, the file-based sessions are not going to work -- as the files for the session might end up on a different server.
Hi,
I've tried to create a multiform but got stuck in PHP sessions. The session doesn't start when added
includes/
$this->loader->add_action( 'wp_ajax_public_start_form_session', $plugin_public, 'start_form_session' );
$this->loader->add_action( 'wp_ajax_nopriv_start_form_session', $plugin_public, 'start_form_session' );
public/
public function start_form_session() {
if (session_status() === PHP_SESSION_NONE) {
session_start();
}
}
Anybody that can point me to the right direction? :)
The text was updated successfully, but these errors were encountered: