Page 1 of 1

PHP Session Warning on Windows

Posted: Wed Aug 03, 2005 9:05 am
by quadoc
I've the following code in my index.php script. When I run it it gave me the following warning below. I even included the init_set but that doesn't tell me anything. Does anyone know why? Please post some tips. Thanks... :?

// user index.php
include("config.php");

ob_start();
session_start();

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

//connect to database
$connectionstring = odbc_connect($DSN_NAME, $DSN_USER, $DSN_PASSWORD);


Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\Inetpub\wwwroot\schoolProject\config.php:63) in c:\Inetpub\wwwroot\schoolProject\index.php on line 7

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\Inetpub\wwwroot\schoolProject\config.php:63) in c:\Inetpub\wwwroot\schoolProject\index.php on line 7

Posted: Wed Aug 03, 2005 9:09 am
by hawleyjr
you are printing something to the screen either in this file or the config.php put the session_start() on the very top.

Posted: Wed Aug 03, 2005 9:11 am
by mickd
can also use obstart();

http://au3.php.net/manual/sv/function.ob-start.php

at the top of each page and ob_end_flush(); to tell it when to output it

http://au3.php.net/manual/sv/function.ob-start.php

Posted: Wed Aug 03, 2005 11:32 am
by timvw
Given the calls to ini_set i suppose it was my suggestion ;) (Although i said to PRE-pend your files with those lines.. So code becomes:)

Code: Select all

ini_set('error_reporting', E_ALL);
ini_set('display_errors', TRUE);

ob_start();
session_start(); // actually ob doesn't buffer calls to headers, so it doesn't really help when a session-cookie is sent.

// user index.php
include("config.php");

//connect to database
$connectionstring = odbc_connect($DSN_NAME, $DSN_USER, $DSN_PASSWORD);

Re: PHP Session Warning on Windows

Posted: Wed Aug 03, 2005 11:49 am
by nielsene
quadoc wrote:
Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at c:\Inetpub\wwwroot\schoolProject\config.php:63) in c:\Inetpub\wwwroot\schoolProject\index.php on line 7

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at c:\Inetpub\wwwroot\schoolProject\config.php:63) in c:\Inetpub\wwwroot\schoolProject\index.php on line 7
Check the bottom of you config.php file. Sounds like you probably have some whitespace after the closing ?> tag.

Posted: Wed Aug 03, 2005 5:11 pm
by feyd
ob_start = band-aid.