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
Related
Is there any server/hosting setting that could cause simple redirect in Yii2 to not work?
For example:
function actionIndex(){
return $this->redirect('other-page');
}
This code ends up with a blank page, no errors or messages are displayed(Error reporting is on), response code is 200 (although Yii2 debugger shows 302). Everything on my website works fine but as soon as code reaches any ->redirect() it just end up with blank page.
This happens only on my clients shared hosting (on my local machine and development shared hosting everything works just fine).
Yii2 runtime logs does not show any errors, neither server logs that my hosting is giving me access to.
It turned out that this was standard white page error: additional new blank line at the beginning of a php file.
I went through framework files, line by line. When I commented out if(headers_sent()) {return;} Yii finally threw an exception, only to let me find out that one of my config files had extra new line at the beginning of the file. Removing it fixed the problem.
Make sure that no header sent before you send redirect response.
Also check your php file encoding, if you're using UTF-8 make sure that it's UTF-8 encode without BOM.
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 just changed a couple of websites from an old web server to a new one.
This error is occurring in various pages of the e-commerce website.
Any idea of what it could be?
this may sometimes happen because of something being send to the browser before the session this could be be a space at the start of a php script or a BOM unicode in your file that cause that problem.
1.Remove Whitespaces before and after PHP Tags. It may give "Cannot send session cache limiter " Warning.
2.If SESSION is already enabled in PHP.ini, then no need to write session_start(); Statement.
3.If SESSION is disabled in PHP.ini, then keep "session_start();" Statement only once in your application.
This can be because of something that I faced with before:
You have something before session_start(); in your codes. Make sure that this code is the fist line after <?php in your code.
We have something called BOM in php files. You can set or unset this option while you are saving your php file. For PHP files, this option has to be unset. Otherwise you will get your mentioned error.
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
This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
“Warning: Headers already sent” in PHP
I tried using xampp lite portable in my flash drive so that I could bring the server anywhere.
But I always get an error when using xampp. This error in particular:
Warning: Cannot modify header information - headers already sent by (output started at /path/to/geeklog/public_html/blabla.php:581) in /path/to/geeklog/public_html/system/lib-blablab.php on line 180
I don't know why I'm getting this error. But when I use wampserver. There's really no problem. And I don't get any errors. What do I need to do to solve this when I'm using xampp.
Is there a portable version of wamp
To ensure your error reporting level is the same across environments, you can set it in your application using error_reporting() and ini_set('display_errors', 1)
Also check your .php files for any whitespace before the opening tag and after the closing tag.
In addition to the points mentioned above, ensure you are not outputting anything before the headers are set, for example the following code would produce an error similar to the one you are receiving:
echo 'Hello, World';
header('Location: http://www.somesite.com');
Is it possible there's a little bitty bit of whitespace outside of the PHP tags in blabla.php line 581? I bet there is.
See, if you have anything outside of PHP tags, that is sent to the browser. And once something has been sent to the browser, you can't send headers (like the sessionID cookies!) anymore.
The problem is likely not XAMPP, but your PHP code as you put it on the flash drive.
The difference you're seeing between environments is most almost certainly a difference in the configuration.
One of two things is happening on the server that isn't emiting Warnings:
1) Output buffering is on by default
2) error_reporting and/or display_errors is set so you're just not seeing the warnings. But if this were the case, your headers still wouldn't get set, so it's probably #1
You can check these settings by looking at the output from phpinfo()
Output buffering, when enabled, buffers any output (regular content not inside tags, anything you echo or print(), etc) on the server and then sends it to the client in one shot.
I'd poke around in your portable version, find php.ini, and try turning output buffering on. Alternatively, you can turn output buffering on at runtime by sticking ob_start() near the top of your script.
The error states: output started at /path/to/geeklog/public_html/blabla.php:581, so I would start there. You need to send all headers before outputting anything, this includes whitespace as mentioned by others here.