-2

I am having this error in PHP:

session_start(): Cannot send session cache limiter - headers already sent

I know I have to put session_start() even before the html <head>, what I am doing. The issue here is that I am using id containers for ajax generated content.

For example, I have a button in the homepage.php which updates some calculate.php file in a divResults, and this calculate.php begins with session_start(). However, this warning is appearing inside divResults.

How could I solve it. Is it possible to simply ignore the warning. How?

(I don't have this problem in XAMPP, only using an external hosting provider) Thanks

Mr Lister
  • 45,515
  • 15
  • 108
  • 150
Tomsss
  • 63
  • 6
  • 1
    `session_start();` must be first line in `php` after ` – Alive to die - Anant Feb 20 '16 at 16:51
  • I am doing that. But the problem occurs with the .php that is updating in a div container of the homepage. – Tomsss Feb 20 '16 at 16:52
  • I have a homepage.php which contains some "divResults". The divResults is updated through $.ajax jquery, calling calculate.php. The file calculate.php starts with session_start();. However, it is showing this warning INSIDE divResults, so, because of the other php file. – Tomsss Feb 20 '16 at 16:59
  • 1
    You are not allowed to send any output **before** sending the headers. Make sure you don't make any outputs (no plain html, no php echo, no whitespace, absolutely nothing). – Charlotte Dunois Feb 20 '16 at 17:06
  • SOLVED. it was just because of an empty line in the beginning the the .php file. Thanks – Tomsss Feb 20 '16 at 17:06

1 Answers1

1

Based on your problem following errors may possible.

  1. you write session_start(); in somewhere middle or end of the .php file so you need to put session_start();at top of .php file just after <?php.

  2. May be some empty lines are there in your .php file at the beginning or end, because of that also this error will arise. remove those empty line.

Alive to die - Anant
  • 70,531
  • 10
  • 51
  • 98