Title: Session warning
Last modified: November 30, 2023

---

# Session warning

 *  Resolved [Larry Lewis](https://wordpress.org/support/users/jenolan/)
 * (@jenolan)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/)
 * 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)
 *     ```wp-block-code
       [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](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240536)
 * 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](https://wordpress.org/support/users/jenolan/)
 * (@jenolan)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240568)
 * I would hazard a guess it is happening inside cron call, I read somewhere that
   current php you can not use reliably(line 25);
 *     ```wp-block-code
       if (php_sapi_name() !== 'cli') {
       ```
   
 * trying to find the explanation, will post when/if found
 *  Plugin Author [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240591)
 * Interesting. Which version of PHP are you using?
 *  Thread Starter [Larry Lewis](https://wordpress.org/support/users/jenolan/)
 * (@jenolan)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240617)
 * 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;
 *     ```wp-block-code
       */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](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240622)
 * 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](https://wordpress.org/support/users/jenolan/)
 * (@jenolan)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240639)
 * Fixed, at the top of wp-cron.php it is sending headers which then causes the 
   session setting to fail….
 *     ```wp-block-code
       <?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](https://wordpress.org/support/users/specialk/)
 * (@specialk)
 * [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240707)
 * 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.

 * ![](https://ps.w.org/simple-ajax-chat/assets/icon-256x256.png?rev=1473439)
 * [Simple Ajax Chat – Add a Fast, Secure Chat Box](https://wordpress.org/plugins/simple-ajax-chat/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-ajax-chat/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-ajax-chat/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-ajax-chat/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-ajax-chat/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-ajax-chat/reviews/)

 * 7 replies
 * 2 participants
 * Last reply from: [Jeff Starr](https://wordpress.org/support/users/specialk/)
 * Last activity: [2 years, 6 months ago](https://wordpress.org/support/topic/session-warning-2/#post-17240707)
 * Status: resolved