Title: session_start() conflict
Last modified: March 11, 2020

---

# session_start() conflict

 *  Resolved [John Huebner](https://wordpress.org/support/users/hube2/)
 * (@hube2)
 * [6 years, 5 months ago](https://wordpress.org/support/topic/session_start-conflict/)
 * I am seeing the following error on a site
 * > PHP Warning: session_start(): Cannot send session cookie – headers already 
   > sent in
 * I have tracked this down to 2 plugins calling session_start() The other plugin
   calls it on “init”. This plugin calls on line 144 of
 * > plugins/wp-mail-smtp/vendor/phpseclib/phpseclib/phpseclib/Crypt/Random.php
 * Please give me suggestions on how to prevent this conflict

Viewing 5 replies - 1 through 5 (of 5 total)

 *  [Sanjeev Aryal](https://wordpress.org/support/users/sanzeeb3/)
 * (@sanzeeb3)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12539625)
 * Hi [@hube2](https://wordpress.org/support/users/hube2/),
 * What is the other plugin creating the issue? This issue doesn’t mean the error
   comes from the WP Mail SMTP plugin. Please consider isolating the plugins to 
   find the real conflict. The error might still be there without one another or
   the plugin needs to check if session already exists. You might still need to 
   contact the other plugin support.
 * I hope this helps!
 *  Thread Starter [John Huebner](https://wordpress.org/support/users/hube2/)
 * (@hube2)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12540159)
 * This should be extremely simple for you to test.
 * The other plugin is a plugin that I have created for a client that manages a 
   shopping cart, so I can adjust it if you tell me how not to conflict with your
   plugnin.
 * All you need to test is to put this into the function.php file of any site that’s
   running this plugin:
 *     ```
       add_action('init', 'my_session_start');
       function my_start_session() {
         if (!session_id()) {
           session_start();
         }
       }
       ```
   
 * This will cause your plugin to produce warnings, and yes, it is the code in this
   plugin that is producing the errors. I have tried to change the priority of my
   action and this has had no effect whatsoever. I have tried looking at what the
   code mentioned above does and tried to figure out “WHEN” it is called, but have
   been unable to do so.
 * As far as I know I am starting my session exactly as I should be doing it following
   WP best practices.
 *  [Sanjeev Aryal](https://wordpress.org/support/users/sanzeeb3/)
 * (@sanzeeb3)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12551842)
 * Hi [@hube2](https://wordpress.org/support/users/hube2/),
 * Thanks for the details. I am not able to reproduce the issue you’re describing.
   Probably, you have something already printed on the page. Also, the name of the
   function ‘my_start_session’ does not match with ‘my_session_start’.
 * Thanks!
 *  [Sanjeev Aryal](https://wordpress.org/support/users/sanzeeb3/)
 * (@sanzeeb3)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12581407)
 * Hi [@hube2](https://wordpress.org/support/users/hube2/) – We haven’t heard from
   you in about a week, so I’m going to go ahead and mark this ticket resolved. 
   If you still have questions, though, please feel welcome to continue the conversation.
 *  Thread Starter [John Huebner](https://wordpress.org/support/users/hube2/)
 * (@hube2)
 * [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12591289)
 * Sorry I didn’t get back to this sooner. Yes, this is resolved here. The session
   conflict appears to be something else. Still working on trying to figure out 
   what.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘session_start() conflict’ is closed to new replies.

 * ![](https://ps.w.org/wp-mail-smtp/assets/icon-256x256.png?rev=1755440)
 * [WP Mail SMTP by WPForms - The Most Popular SMTP and Email Log Plugin](https://wordpress.org/plugins/wp-mail-smtp/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-mail-smtp/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-mail-smtp/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-mail-smtp/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-mail-smtp/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-mail-smtp/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [John Huebner](https://wordpress.org/support/users/hube2/)
 * Last activity: [6 years, 4 months ago](https://wordpress.org/support/topic/session_start-conflict/#post-12591289)
 * Status: resolved