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
Related
I have a project which calls lots of AJAX PHP pages which have session_start(); called. It works fine in a WAMP server (localhost) but when I host this project on a live server it shows:
Warning: session_start(): Cannot send session cache limiter - headers already sent message
This warning error is removable when I remove session_start(); in AJAX PHP pages
and program works fine in live server but not in WAMP server (localhost) program fails.
Is there something that I have to configure in the WAMP server which works exactly like live server?
Typically, you need to have session_start(); only in the first PHP file you're loading - consequent loads of PHP pages will use the same session.
session_start(); creates a new session which will be used wherever $_SESSION variables are accessed, even in other PHP pages in the same context.
Please refer the documentation for session_start()
For the past years we have used a local application that uploads articles to our Joomla homepage (Using a PHP Script). After the latest update to Joomla 3.6 (Used to be 3.5) that application no longer works. The following error occurs:
Error displaying the error page: Application Instantiation Error: Failed to start the session because headers have already been sent by "/var/www/DOMAIN/htdocs/FOLDER/execute.php" at line 1.
There used to be an "application.php" file inside ./htdocs/FOLDER/administrator/includes/ and after the update the file disappeared. It looks like the script can't create an instance of the application. I have already tried to repair the Database using the Back End option, but that didn't solve the problem.
Update: The above error occurs at:
$mainframe = JFactory::getApplication('administrator');
Help is much appreciated!
Some text is being output by "/var/www/DOMAIN/htdocs/FOLDER/execute.php", probably white space at line one. Check nothing is output before sending any headers.
Not a great resolution but you could also clean the output buffer before the header fn. Have a read of ob_clean()
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'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?
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