Jump to content

Cannot send session cookie - headers already sent NOT SIMPLE


TeddyKiller

Recommended Posts

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/l/o/s/lostignorance/html/test/includes/Login2/config.php:1) in /home/content/l/o/s/lostignorance/html/test/includes/Login2/session.php on line 18

 

This seems simple. only it's not. theres no whitespace, nothing being executed before session_start. All it is, is php.

My config is the same as this, and it works fine... yet it doesn't on here. Line 18, is session_start, its a class I use on my site and it works fine. This isn't the problem. I am 100% sure of it.

 

This is my page..

<?php
include("includes/Login2/config.php");

echo 'Stuffs';
?>

 

config.php, is as follows

<?php
define('DB_SERVER', "server");
define('DB_USER', "user");
define('DB_PASS', "pass");
define('DB_NAME', "name");

define("COOKIE_EXPIRE", 31536000); //1 Year
  
require_once("includes/Login2/db.php");

require_once("includes/Login2/functions.php");

require_once("includes/Login2/user.php");

require_once("includes/Login2/session.php");

$database = DatabaseAdapterFactory::factory('mysql', DB_SERVER, DB_USER, DB_PASS, DB_NAME);
$database->connect();

$session = new Session;

$secret_key = '103041231';

require_once("includes/Login2/form.php");

$form = new Form();

if(isset($_SESSION['uid']) && isset($_SESSION['hash'])) {
    $user = $session->checkLogin($secret_key);
}

require_once("includes/Login2/mailer.php");

$mailer = new Mailer(''site name', 'email');

require_once("includes/Login2/settings.php");

$settings = new Settings();

?>

 

As you see.. no html executed, no whitespace, nothing. Though it doesn't work.. wtf is going on? Seriously need some help.

 

new Session, is when it initializes Session, so thats when it creates a session start

Link to comment
Share on other sites

I think he may save as ANSI, I can't remember what the default format is in Notepad++.  I save under Unix UTF-8, so I'll confer with him.

 

I believe ANSI was default, but if he is saving under UTF-8, is there any other possibilities which could cause this error?

And would ANSI cause this error as well?

 

So .. I shouldn't be saving as UTF-8?  I should be saving as UTF-8 without BOM.  I'll google again, sorry for being a nub about encoding.

Link to comment
Share on other sites

Is that a direct copy and paste from your code?

 

This line

 

mailer = new Mailer(''site name', 'email');

 

has two single quotes before 'site name', which would throw an error, which could break your session_start() if the error is thrown first.

Link to comment
Share on other sites

Is that a direct copy and paste from your code?

 

This line

 

mailer = new Mailer(''site name', 'email');

 

has two single quotes before 'site name', which would throw an error, which could break your session_start() if the error is thrown first.

No, it had proper values and I editted them. - That was just a typo.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.