Unyson icon indicating copy to clipboard operation
Unyson copied to clipboard

PHP Warning: session_start()

Open fotan opened this issue 2 years ago • 4 comments

PHP Log is filling up with these.

PHP Warning: session_start(): Cannot start session when headers already sent in /home/customer/www/xxxxxxxx/public_html/wp-content/plugins/unyson/framework/helpers/class-fw-session.php on line 13

fotan avatar Sep 16 '22 16:09 fotan

here, too

PHP Warning: session_start(): Session cannot be started after headers have already been sent in /.../wp-content/plugins/unyson/framework/includes/hooks.php on line 259

The problem is still relevant

zhelnitskiy avatar Oct 27 '22 12:10 zhelnitskiy

+1

The plugin also causes this in Site Health:

An active PHP session was detected

Performance

A PHP session was created by a session_start() function call. This interferes with REST API and loopback requests. The session should be closed by session_write_close() before making any HTTP requests.

bakkbone avatar Nov 17 '22 08:11 bakkbone

same issue here, have you found a fix? image

	 * Start the session before the content is sent to prevent the "headers already sent" warning
	 * @internal
	 */
	function _action_fw_flash_message_backend_prepare() {
		if ( apply_filters( 'fw_use_sessions', true ) && ! session_id()  ) {
			**session_start();**
		}
	}





			/**
			 * In ajax it's not possible to call flash message after headers were sent,
			 * so there will be no "headers already sent" warning.
			 * Also in the Backups extension, are made many internal ajax request,
			 * each creating a new independent request that don't remember/use session cookie from previous request,
			 * thus on server side are created many (not used) new sessions.
			 */
			! ( defined( 'DOING_AJAX' ) && DOING_AJAX )
			&&
			! session_id()
		) {
			**session_start();**
		}
	}

yarlevi avatar Feb 27 '23 09:02 yarlevi

I dropped this into the plugin. Hopefully they can make this permanent. stackoverflow.com

Changed session_start(); to session_start(['read_and_close' => true,]); in:

unyson/framework/helpers/class-fw-session.php line 13 unyson/framework/includes/hooks.php lines 229 and 259

Spleeding1 avatar Mar 16 '23 16:03 Spleeding1