Title: session_start()
Last modified: May 18, 2023

---

# session_start()

 *  [Alex](https://wordpress.org/support/users/alexandronalin/)
 * (@alexandronalin)
 * [3 years ago](https://wordpress.org/support/topic/session_start-2/)
 * 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](https://wordpress.org/support/users/e4jvikwp/)
 * (@e4jvikwp)
 * [3 years ago](https://wordpress.org/support/topic/session_start-2/#post-16751000)
 * 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:
 *     ```wp-block-code
       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](https://wordpress.org/support/users/alexandronalin/)
 * (@alexandronalin)
 * [3 years ago](https://wordpress.org/support/topic/session_start-2/#post-16752163)
 * 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](https://wordpress.org/support/users/e4jvikwp/)
 * (@e4jvikwp)
 * [3 years ago](https://wordpress.org/support/topic/session_start-2/#post-16752306)
 * 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](https://stackoverflow.com/questions/42827556/php-5-6-headers-sent-intermittently-returns-true-empty-file-name-and-line-0),
   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](https://wordpress.org/support/users/alexandronalin/)
 * (@alexandronalin)
 * [3 years ago](https://wordpress.org/support/topic/session_start-2/#post-16752567)
 * Understand.
 * thanks for help

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

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

 * ![](https://ps.w.org/vikappointments/assets/icon-256x256.png?rev=2127296)
 * [VikAppointments Services Booking Calendar](https://wordpress.org/plugins/vikappointments/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/vikappointments/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/vikappointments/)
 * [Active Topics](https://wordpress.org/support/plugin/vikappointments/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/vikappointments/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/vikappointments/reviews/)

 * 4 replies
 * 2 participants
 * Last reply from: [Alex](https://wordpress.org/support/users/alexandronalin/)
 * Last activity: [3 years ago](https://wordpress.org/support/topic/session_start-2/#post-16752567)
 * Status: not resolved