Title: PHP Warning: session_start(): Cannot start session when headers already sent
Last modified: October 8, 2020

---

# PHP Warning: session_start(): Cannot start session when headers already sent

 *  Resolved [Christiaan van Luik](https://wordpress.org/support/users/cvl01/)
 * (@cvl01)
 * [5 years, 8 months ago](https://wordpress.org/support/topic/php-warning-session_start-cannot-start-session-when-headers-already-sent-2/)
 * Hello,
 * The plugin is throwing a warning in routes.php
 * `PHP Warning: session_start(): Cannot start session when headers already sent
   in wp-content/plugins/simple-jwt-login/routes.php on line 15`
 * Is this a problem you are aware of?
 * I fixed it by changing the code to
 *     ```
       if( empty(session_id()) && !headers_sent()){
           session_start();
       }
       ```
   

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

 *  Plugin Author [Nicu Micle](https://wordpress.org/support/users/nicu_m/)
 * (@nicu_m)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-session_start-cannot-start-session-when-headers-already-sent-2/#post-13534762)
 * Hello Christiaan,
 * Thank you for the heads up and for offering the solution.
 * I will add this fix in the new release. I hope this will happen by the end of
   the week.
 * I will come back with updates.
 * Best regards,
    Nicu.
 *  [mradminusertive](https://wordpress.org/support/users/mradminusertive/)
 * (@mradminusertive)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-session_start-cannot-start-session-when-headers-already-sent-2/#post-13542223)
 * I can confirm, that this issue exists and is really annoying. I have found out
   that the issue appears when WP CLI runs periodically tasks. I don’t know even
   why this plugin is running in WP CLI mode. Complete stack trace can be found 
   here:
    [https://hastebin.com/loyufapano.sql](https://hastebin.com/loyufapano.sql)
 * Keep doing your great job man. Your making headless world of WP available.
 *  Plugin Author [Nicu Micle](https://wordpress.org/support/users/nicu_m/)
 * (@nicu_m)
 * [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-session_start-cannot-start-session-when-headers-already-sent-2/#post-13559119)
 * Hello,
 * This issue should be fixed in version 2.4.0.
 * Can you please update the plugin and let me know how it goes?
 * PS: thank you [@cvl01](https://wordpress.org/support/users/cvl01/) for suggesting
   a fix.
 * Best regards, Nicu.

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

The topic ‘PHP Warning: session_start(): Cannot start session when headers already
sent’ is closed to new replies.

 * ![](https://ps.w.org/simple-jwt-login/assets/icon-256x256.png?rev=2106097)
 * [Simple JWT Login – Allows you to use JWT on REST endpoints.](https://wordpress.org/plugins/simple-jwt-login/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/simple-jwt-login/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/simple-jwt-login/)
 * [Active Topics](https://wordpress.org/support/plugin/simple-jwt-login/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/simple-jwt-login/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/simple-jwt-login/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [Nicu Micle](https://wordpress.org/support/users/nicu_m/)
 * Last activity: [5 years, 7 months ago](https://wordpress.org/support/topic/php-warning-session_start-cannot-start-session-when-headers-already-sent-2/#post-13559119)
 * Status: resolved