0
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/moonpk/public_html/wallz/preview.php:16) in /home/moonpk/public_html/wallz/loginbox.php on line 2

 Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/moonpk/public_html/wallz/preview.php:16) in /home/moonpk/public_html/wallz/loginbox.php on line 2

i am getting these two warning which i was not getting on local server... why ....

Moon
  • 19,518
  • 56
  • 138
  • 200

5 Answers5

2

See the first note on the php session_start() page. session_start() sends cookies to the browser, and the server will not send any additional data (including cookies) after any data has already been sent. This can simply be fixed by making sure that nothing is being sent to the browser (such as an echo() or var_dump() call) before calling session_start().

eykanal
  • 26,437
  • 19
  • 82
  • 113
  • It’s rather the server that can’t modify the header after it has been sent. – Gumbo Nov 23 '10 at 19:40
  • whats the use of the sessions and php if i cannot echo after session_start() – Moon Nov 23 '10 at 19:46
  • You read it wrong... you cannot echo BEFORE session_start(). – eykanal Nov 23 '10 at 19:47
  • sorry that was some strange kind of typo (not syntax typo but logical typo error, lol) why no echo before session_start().. do the echos scare the session away – Moon Nov 24 '10 at 07:03
1

Most likely you have some whitespace outside any PHP-tags in files that are loaded before the session_start() is executed. Maybe your FTP client messed things up?

Martin Schapendonk
  • 12,893
  • 3
  • 19
  • 24
1

You don't get them on local server because you have lower errer reporting level on it. So, you need:

  1. On you local server edit php.ini and set error_reporting to E_ALL
  2. Move you session_start() call before line 16 of you /home/moonpk/public_html/wallz/preview.php file
seriyPS
  • 6,817
  • 2
  • 25
  • 16
0

You probably had warnings suppressed on your local server? The issue is that you have some output before you call session_start. Judging by the line numbers, I'd guess you have a line break before your opening php tag, but without seeing the code, can't provide a full solution.

Gazler
  • 83,029
  • 18
  • 279
  • 245
  • before session_start i am doing some `echo` s but whats difference doesn't it make.. and yes my session_start() is not the first line of page.. its the first line of a php page which i include some where below the ..... i got rid of warning by `error_reporting(0);` whats the worst & why it shouldn't be like that... – Moon Nov 24 '10 at 06:58
-1

If you are including the page "preview.php" within "loginbox.php" check that you have only called session_start once on one page.

Either on preview.php or loginbox.php , not both.

Elliott
  • 3,812
  • 24
  • 69
  • 93