• Alex

    (@alexandronalin)


    Hi,

    today I checked my error.log file in my public_html by chance and I found lot of this rows:

    PHP Warning: session_start(): Session cannot be started after headers have already been sent in /abc/def/public_html/wp-content/plugins/vikappointments/libraries/adapter/session/handler.php on line 31

    A row every 2-3-4 time for minute since april (log starts from april)

    All plugins patched and wordpress at last version with php8.0

    Have you ever seen this error?

    Many thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author e4jvikwp

    (@e4jvikwp)

    Hi,

    VikAppointments starts the session during the “init” hook. If you are obtaining that error, you are probably using a theme/plugin that echoes (displays) something before (or during) the WordPress initialization.

    It is possible to include an additional PHP test code to detected who is sending the headers too early.

    You should open via FTP (or through the plugin editor) the file mentioned in the error log:
    wp-content/plugins/vikappointments/libraries/adapter/session/handler.php

    Here you should replace the code at line 31 into the following one:

    if (headers_sent($file, $line))
    {
        file_put_contents(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'log.txt', "File: $file\nLine: $line\n");
    }
    else
    {
        session_start();
    }

    At this point, when you try to visit a page from the front-end, this code should be executed and a log file will be generated, which will contain the file and the line that are currently sending the headers. You can find this file at the path below:
    wp-content/plugins/vikappointments/libraries/adapter/session/log.txt

    Thread Starter Alex

    (@alexandronalin)

    Hi,

    unfortunately no output. The log.txt have just 2 line inside:

    File:
    Line: 0

    nothing else ??

    log.txt timestamp changes every minute, so I assume your code is executed

    Plugin Author e4jvikwp

    (@e4jvikwp)

    Hi,

    if you are obtaining a similar log, the headers are sent outside from PHP. There’s no article on the web that explains why and when headers_sent fills the name of the file with an empty string.

    I believe that you should contact your hosting provider to analyze your situation.

    I found a similar case on StackOverflow, but unfortunately none was able to provide a relevant solution.

    I would suggest to try migrating the website into a different server/hosting, but this procedure might take you some time.

    You can also try to deactivate all your installed plugins one by one. In case this procedure solves the issue, one of your plugins probably contains PHP code saved with a wrong encoding (probably UTF-8 BOM).

    Thread Starter Alex

    (@alexandronalin)

    Understand.

    thanks for help

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘session_start()’ is closed to new replies.