Welcome Guest, Not a member yet? Register   Sign In
headers already sent problem
#1

[eluser]maks80[/eluser]
Hi,

I've just started to use CodeIgniter and I have big problem on the begining with sessions or sending cookies.
Here is page with error.
error page
This page is CodeIgniter 1.5.4, after downloading I just added session library to autoload.php and I didn't change anything more.
Could you advice me how I can solve the problem?
#2

[eluser]leonglass[/eluser]
I would have thought that the problem is you are using the session after the view has already started producing the page. Headers already sent errors mean that the page output has already begun. As you can see from my post count I am pretty new here myself so not that well versed with CI yet either. At which point are you calling the session start method? It has to be done before you issue any print or echo statements. Sometimes it is ok (as your error page has produced the welcome page) to use for debugging purposes so you can print some text in your model or controller portions to see what is happening and this will generate the error but the rest of the page is still rendered.
#3

[eluser]maks80[/eluser]
I didn't change "welcome" controller:
Code:
<?php

class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
    }
    
    function index()
    {
        $this->load->view('welcome_message');
    }
}
?>
I started session using autoload.php
Code:
$autoload['libraries'] = array('session');
So it should be before the view has already started producing the page.
#4

[eluser]smith[/eluser]
It is possible that you are printing space somewhere during session setup.
Did you try to set some session variables? are you sure that your .htaccess is ok?

you didn't tell us everything, you are using cookies too...
your script breaks while trying to set cookie
#5

[eluser]maks80[/eluser]
Quote:It is possible that you are printing space somewhere during session setup.
I didn't change anything in scripts after I downloaded it from CodeIgniter webpage.

Quote:Did you try to set some session variables?
...
you didn’t tell us everything, you are using cookies too…
your script breaks while trying to set cookie

Yes, but still is the same. Here is link to my test page and below is my controller.
Code:
class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();    
        $this->load->helper('cookie');
        
        $cookie = array(
                   'name'   => 'Name',
                   'value'  => 'The Value',
                   'expire' => '86500',
                   'domain' => 'some-domain.com',
                   'path'   => '/',
                   'prefix' => '',
               );

        set_cookie($cookie);
        
        $this->session->set_userdata('some_name', 'some_value');
    }
    
    function index()
    {
        $this->load->view('welcome_message');
    }
}

Quote:are you sure that your .htaccess is ok?
I dont have .htaccess.
#6

[eluser]smith[/eluser]
what is the content of this file:
/usr/local/apache/www/htdocs/fcliverpool.pl/test/zuzel/index.php

also, codeigniter includes .htaccess by default
#7

[eluser]maks80[/eluser]
[quote author="smith" date="1192376509"]what is the content of this file:
/usr/local/apache/www/htdocs/fcliverpool.pl/test/zuzel/index.php

also, codeigniter includes .htaccess by default[/quote]

index.php is a standard index form CodeIgniter I didn't change anything:
Code:
<?php
/*
|---------------------------------------------------------------
| PHP ERROR REPORTING LEVEL
|---------------------------------------------------------------
|
| By default CI runs with error reporting set to ALL.  For security
| reasons you are encouraged to change this when your site goes live.
| For more info visit:  http://www.php.net/error_reporting
|
*/
    error_reporting(E_ALL);

/*
|---------------------------------------------------------------
| SYSTEM FOLDER NAME
|---------------------------------------------------------------
|
| This variable must contain the name of your "system" folder.
| Include the path if the folder is not in the same  directory
| as this file.
|
| NO TRAILING SLASH!
|
*/
    $system_folder = "system";

/*
|---------------------------------------------------------------
| APPLICATION FOLDER NAME
|---------------------------------------------------------------
|
| If you want this front controller to use a different "application"
| folder then the default one you can set its name here. The folder
| can also be renamed or relocated anywhere on your server.
| For more info please see the user guide:
| http://www.ellislab.com/codeigniter/user-guide/general/managing_apps.html
|
|
| NO TRAILING SLASH!
|
*/
    $application_folder = "application";


/*
|===============================================================
| END OF USER CONFIGURABLE SETTINGS
|===============================================================
*/


/*
|---------------------------------------------------------------
| SET THE SERVER PATH
|---------------------------------------------------------------
|
| Let's attempt to determine the full-server path to the "system"
| folder in order to reduce the possibility of path problems.
| Note: We only attempt this if the user hasn't specified a
| full server path.
|
*/
if (strpos($system_folder, '/') === FALSE)
{
    if (function_exists('realpath') AND @realpath(dirname(__FILE__)) !== FALSE)
    {
        $system_folder = realpath(dirname(__FILE__)).'/'.$system_folder;
    }
}
else
{
    // Swap directory separators to Unix style for consistency
    $system_folder = str_replace("\\", "/", $system_folder);
}

/*
|---------------------------------------------------------------
| DEFINE APPLICATION CONSTANTS
|---------------------------------------------------------------
|
| EXT        - The file extension.  Typically ".php"
| FCPATH    - The full server path to THIS file
| SELF        - The name of THIS file (typically "index.php)
| BASEPATH    - The full server path to the "system" folder
| APPPATH    - The full server path to the "application" folder
|
*/
define('EXT', '.'.pathinfo(__FILE__, PATHINFO_EXTENSION));
define('FCPATH', __FILE__);
define('SELF', pathinfo(__FILE__, PATHINFO_BASENAME));
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }

    define('APPPATH', BASEPATH.$application_folder.'/');
}

/*
|---------------------------------------------------------------
| DEFINE E_STRICT
|---------------------------------------------------------------
|
| Some older versions of PHP don't support the E_STRICT constant
| so we need to explicitly define it otherwise the Exception class
| will generate errors.
|
*/
if ( ! defined('E_STRICT'))
{
    define('E_STRICT', 2048);
}

/*
|---------------------------------------------------------------
| LOAD THE FRONT CONTROLLER
|---------------------------------------------------------------
|
| And away we go...
|
*/
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;
?>

Where I can finde .htacces, because I didn't create it and I can't finde it in downloaded package.
#8

[eluser]nmweb[/eluser]
You don't need it anyway, but you can find it in the wiki. Search for it and you will find it. Problem you encounter is that you output something before you send the cookies. Make sure you delete all spaces before or after the <?php or ?> in the files you modified. Double check this.
#9

[eluser]Majd Taby[/eluser]
this happens when you have either a new line before/after you <?php ?> tags, or even a single space, make sure you check for that
#10

[eluser]Derek Allard[/eluser]
Agreed with Zaatar. http://expressionengine.com/knowledge_ba...formation/




Theme © iAndrew 2016 - Forum software by © MyBB