Support » Plugin: Advanced Forms » PHP Warnings: Cannot start session when headers already sent

  • Resolved hwk-fr

    (@hwk-fr)


    Hey!

    I just would like to let you know that Advanced Forms fills de debug.log with PHP Warnings:

    session_start(): Cannot start session when headers already sent in /wp-content/plugins/advanced-forms/api/api-submissions.php on line 39

    Here is a quick fix:

    In /wp-content/plugins/advanced-forms/api/api-submissions.php line 39

    Replace:
    if( '' == session_id() ) {

    With:
    if( !headers_sent() && '' == session_id() ) {

    PS: I’m using Advanced Forms with custom Ajax requests & submission.

    Thanks in advance buddy!

    Regards.

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author fabianlindfors

    (@fabianlindfors)

    That’s weird!

    I think my plugin might not be the one sending headers that early. The submission code is triggered very early in the request, way before any data should have been sent. Could you try disabling all plugins except AF and ACF and see if the warnings are still generated?

    Thanks!

    I’m getting this error too. The problem thing is: Sometimes it pops up, sometimes it doesn’t. So I can’t really point out what plugin would be causing the issue. I’ve had the error log even with just ACF and AF enabled and a WordPress Starter Theme.

    I’ve applied the quick fix provided by hwk-fr for now, but I keep getting the errors on the dev site.

    Thanks!

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Thank you for chiming in. If you every run into this again please send your error log as well, might contain some good pointers!

    I’m not really willing to add the quick fix without getting to the bottom of what could be sending content before the session check that my plugin performs.

    Could you, hwk-fr, tell me more about your custom AJAX request and submissions?

    wiljeonline

    (@wiljeonline)

    Still getting these errors. Here’s a bit of my error log:

    [27-Jun-2019 20:26:11 UTC] PHP Warning: session_start(): Cannot start session when headers already sent in /public_html/wp-content/plugins/advanced-forms-pro/api/api-submissions.php on line 39

    I’m also using custom Ajax requests & submissions.

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi!

    Could you elaborate on what you mean by custom AJAX requests and submissions?

    I’m having the same problem and when researching it further it seems that there is a problem for every site I’ve made that uses Advanced Forms:

    Advanced Forms always sets PHPSESSID -cookie. There aren’t any forms on the front pages but if I “curl –head <mysiteurl>” the PHPSESSID is set. That isn’t good when trying to have a good cache.

    Can you Fabian research this please?

    Also seeing the same warnings.

    @fabianlindfors Is it possible to only start session when a form is loaded?

    Plugin Author fabianlindfors

    (@fabianlindfors)

    Hi! Since 1.6.6 the plugin doesn’t use sessions anymore so this problem should be no more.

    Please get back to me if you run into any other issues!

    @fabianlindfors Thanks for the update. The problem should be solved for us then!

Viewing 10 replies - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.