I'm getting this error all of a sudden - obviously I've changed something but I can't figure out what. I've checked all files for any whitespace before/after the <?php ?> tags but they're all fine.
Warning (2): session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/dev/public_html/app/Controller/PostsController.php:1) [APP/Controller/AppController.php, line 2]
I'm basically using cakephp and hybridauth and it requires you to put session_start() at the beginning of your AppController.php file, which was working fine until recently. On some pages it still works ok without causing any errors, but on others like the homepage I get this error occur now.
Is there any way I can find out what models/controllers/views are being used at this point to determine the difference between the pages when it is and isn't working?
Related
I have a problem while publishing my site. I have a autentication system using session by codeigniter.
When it's run on localhost, its perfect. But when i publish in the server (hosting godaddy), It display this message
Severity: Warning
Message: session_start(): Cannot send session cookie - headers already
sent by (output started at
/home/cristiandelacruz/public_html/crmappsdc/application/config/config.php:1)
Filename: controllers/Login.php
It means you have something output on browser while redirection.
You can do following things:
1) Check which code is printing HTML. And remove it.
eg. Spaces, echo or print statements.
2) if this does not work, add ob_start (); at the file beginning. It stores output in buffer and redirection occurs.
Check if you have blank space before php opening tag in message mentioned file. Try again to save that file without BOM (Copy content into new file and double check you don't have blank space or any characters before file start and save it encoded in UTF-8 without BOM). Maybe helps.
this is happening because your local environment does not have full error reporting turned on, while your hosting provide does. The problem is most likely always there. The reason to that problem is most likely that you are calling Codeigniter's session class $this->session-> ... , however somewhere in the loading of your application, PHP already encountered this: session_start(). To fix it, you need to debug your program and find out where the session is being initialized because the way its currently set up, it is being initialized twice.
Cause:
This error is caused if the your PHP scripts are printing to the browser prior to sending headers. A common example is printing the html tags prior to starting a session, or setting a cookie. The error tells the line that needs to be altered (in this case, it is on /config.php).
Resolution:
To resolve this error remove the lines from the PHP code that are printing to the browser prior to sending headers.
Another common cause for this error is white space either at the beginning or end of the file. The fix is to remove that whitespace from the file. Read the error message carefully. It says output started at ... followed by a file name and a line number. That is the file (and line) that you need to edit. Ignore the second file name - that is only a file that included the file that has the whitespace. The first file is the one you have to edit, not the second one
Source from WHAT DO I DO WHEN I RECEIVE A PHP HEADER ERROR MESSAGE? GoDaddy Forum
Codeigniter Seesion class
I tried above all solutions. finally, I Changed output_buffering in PHP.ini (GoDaddy Server)
output_buffering = on
In PHP 5.4 version by default output_buffering has no value
I updated the PHP version 5.4 to 5.6 and in 5.6 version by default it has value 4096
Now it's working fine
My friend has a wordpress site and wants me to add my premade PHP/Mysql login system. Currently i'm trying to insert PHP pages into the wordpress templates using this plugin: http://www.willmaster.com/software/WPplugins/.
The plugin lets me add php code to the page using this syntax:
[insert_php]
include "account/login.php";
[/insert_php]
However, doing this creates an issues with sessions as the page header is already sent by the wordpress page before the php file is included. I'm getting the following error:
Warning: session_start() [function.session-start]: Cannot send session cache limiter – headers already sent (output started at ...)
Warning: Cannot modify header information – headers already sent by (output started at...
Any ideas how to fix this?
You can write the code for your login at the top in the theme's header.php or simply don't have session_start() in login.php. Or use session_status() to check if the session has started.
You cant start a session after the head becuse data allready started to send to browser. You need to include your code in the head before any code
I used godadday linux server for hosting. I write only <?php session_start();?> on my index.php... I also read so many reviews. I tried but there is no solution. I also take support by godaddy supporters. They said that it is coding problem. But I don't use extra code on my page. I don't understand what is going on there.
session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/26/11511826/html/test/index.php:1) in /home/content/26/11511826/html/test/index.php on line 1
I recently migrated from a Windows to Linux server... now I am getting a bunch of session warnings and some of the content is being loaded properly. On the Windows server, everything worked smooth and I never had any errors, as soon as the migration to Linux took place, I started getting session warnings such as the one below on every page that uses sessions.
I have no idea what I should try or where to begin to address these problems and would appreciate any advice.
I suspect that if session_start() was actully was the problem, I would have gotten a similar warning on the Windows server.
Also my site is hosted by goaddy and I do not have access to the php.ini file...
Warning: session_start() [function.session-start]: Cannot send session
cookie - headers already sent by (output started
at /home/content/12/9453412/html/mainsearch.php:32)
in /home/content/12/9453412/html/mainsearch.php on line 36
Your problem is, that in
/home/content/12/9453412/html/mainsearch.php line 32
(and possibly also in the following ones) you do some kind of output (echo, print, blanks outside of <?php ... ?> etc.), before you do session_start(); on line 36. This is not allowed, as session_start() wants to send headers which is not possible after some kind of output already occured.
Solution: Put your session_start(); to the top of your php file, or at least before you do any kind of output.
And Michael pointed out correctly that this didn't work correctly on you Windows server either, you just didn't know because error reporting was set not to display warnings.
I'm creating a plugin for joomla and it is working as expected in my local Windows 7 machine with WAMP. But when I load the plugin into the production server(Debian), I get this warning (not always):
Warning: Cannot modify header information - headers already sent by (output started at /httpdocs/plugins/system/fiuser.php:1) in /httpdocs/plugins/system/jat3/core/parameter.php on line 73
I tried googling, but it didn't helped me solve the problem actually.
<?php
defined('_JEXEC') or die('Restricted Access');
class plgSystemFiUser extends JPlugin {
// Some functions
}
I get this warning whenever I delete the browsing data from the browser and then the problem persists until I close the browser or go to an another site.
Content of line 73, parameter.php:
setcookie ($this->template.'_tpl', $this->template, $exp, '/');
I'm finding it difficult to debug this problem, as I'm not too much experienced with Joomla and PHP, so any help is appreciated a lot.
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
There is a conflict of the header() method, take a look at flushing the output buffer
PHP.net Output Buffer methods