• Resolved Larry Lewis

    (@jenolan)


    Just noticed a warning in my log files, do not know what the action causing it is but there are quite a few of these happening (with no other WP issues)

    [30-Nov-2023 00:30:01 UTC] PHP Warning:  session_set_cookie_params(): Session cookie parameters cannot be changed after headers have already been sent in .../wp-content/plugins/simple-ajax-chat/simple-ajax-chat-form.php on line 13
    [30-Nov-2023 00:30:01 UTC] PHP Warning:  session_start(): Session cannot be started after headers have already been sent in .../wp-content/plugins/simple-ajax-chat/simple-ajax-chat-form.php on line 15
    

    Thanks!
    Larry

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Jeff Starr

    (@specialk)

    Glad to help. I’m not seeing any errors on default WordPress. So it could be something specific to the site. If you let me know the steps to repeat the error, I will investigate asap.

    Thread Starter Larry Lewis

    (@jenolan)

    I would hazard a guess it is happening inside cron call, I read somewhere that current php you can not use reliably(line 25);

    if (php_sapi_name() !== 'cli') {

    trying to find the explanation, will post when/if found

    Plugin Author Jeff Starr

    (@specialk)

    Interesting. Which version of PHP are you using?

    Thread Starter Larry Lewis

    (@jenolan)

    v8.2 … it is not cli as that was there when I did it from command line as a test.

    It is hitting this warning every cron call, which is invoked as;

    */15 * * * * wget --delete-after https://jenolan.org/wp-cron.php >/dev/null 2>&1

    Just ran it manually and it threw the warning hmmmm I will add some code to your function to see if I can work out why it is triggering ??

    Plugin Author Jeff Starr

    (@specialk)

    Yeah we develop on 8/8.1 primarily. But want to prepare for 8.2 as well. Looking forward to your findings ??

    Thread Starter Larry Lewis

    (@jenolan)

    Fixed, at the top of wp-cron.php it is sending headers which then causes the session setting to fail….

    <?php // Simple Ajax Chat > Chat Form
    
    if (!defined('ABSPATH')) exit;
    
    if (sac_is_session_started() === false) {
    	if( defined( 'DOING_CRON' ) AND DOING_CRON === TRUE )
    	{
    		return;
    	}
    	
    	if (session_status() === PHP_SESSION_NONE) {
    		
    		$simple_ajax_chat_domain = (isset($_SERVER['HTTP_HOST']) && !empty($_SERVER['HTTP_HOST'])) ? sanitize_text_field($_SERVER['HTTP_HOST']) : null;
    		
    		if ($simple_ajax_chat_domain) {
    			session_set_cookie_params('21600', '/', $simple_ajax_chat_domain, false, true);
    			
    			session_start(array('read_and_close' => true));
    			
    		}
    		
    	}
    	
    }
    Plugin Author Jeff Starr

    (@specialk)

    Ah ok, yes that makes sense. I will add a cron check as described for the next plugin update. Thank you very much for your help, Larry. Feel free to post again with any further/related infos.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Session warning’ is closed to new replies.