PHP Session Warning on Windows

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
quadoc
Forum Contributor
Posts: 137
Joined: Fri Jul 01, 2005 5:33 pm
Location: Atlanta, GA

PHP Session Warning on Windows

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post 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.
mickd
Forum Contributor
Posts: 397
Joined: Tue Jun 21, 2005 9:05 am
Location: Australia

Post 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
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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);
User avatar
nielsene
DevNet Resident
Posts: 1834
Joined: Fri Aug 16, 2002 8:57 am
Location: Watertown, MA

Re: PHP Session Warning on Windows

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

ob_start = band-aid.
Post Reply