Cannot modify header information - headers already sent

From Joomla! Documentation

In the HTTP protocol a server response consists of a group of headers followed by a body, separated by a single blank line (i.e. a line containing only a carriage-return). This warning message is produced by PHP if a program attempts to send an additional HTTP header after the separator (and hence all the headers) has already been sent.

By far the most common cause of this problem is that one or more PHP files contains characters (usually a space or an empty line) outside of the <?php and ?> tags. To fix the problem you should examine the PHP file indicated in the warning message and remove any blank characters at the beginning and end of the file. Some text editors, including some online file managers, are prone to automatically adding extraneous line-ending characters at the ends of files, particularly when not configured to do otherwise.

Remove the closing ?> tag at the end of your PHP files. It actually serves no useful purpose as the PHP interpreter knows that end-of-file means end-of-PHP too. Removing it means that any extra blank characters added by your editor will have no effect on the output generated and so will not prevent additional HTTP headers from being sent.

Turn output_buffering setting on php.ini to on to permanently remove this error.[1]

Other Tips
Remove the echo or print or any other statement which prints something on the page. By removing all such statement, this error will be removed and you will be able to modify header information - in other words - you can use the header function.
Go to: Global Configuration/System, disable web services, re-enable web services(if that doesn't work)set session handler to none,(apply)then change back to database(apply) :) Enjoy