#1 (permalink)  
Old 01-15-2009, 12:45 AM
Guybrush's Avatar
Community Manager
 
Join Date: Dec 2008
Location: Brisbane, Australia
Posts: 282
Default Cannot send session cookie - headers already sent

Hi, I'm getting this error, anyone know anything about it?

"Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at C:\xampp\htdocs\index.php:3) in C:\xampp\htdocs\index.php on line 3"


My Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Title Goes Here</title>
<?php session_start(); ?>
</head>

I can't figure out why session_start() is causing an error?
Reply With Quote
  #2 (permalink)  
Old 01-15-2009, 02:22 AM
Guybrush's Avatar
Community Manager
 
Join Date: Dec 2008
Location: Brisbane, Australia
Posts: 282
Default

Heh never mind, I fixed it.

Needed to put <?php session_start(); ?> at line 1.
Reply With Quote
  #3 (permalink)  
Old 01-15-2009, 10:24 AM
Member
 
Join Date: Dec 2008
Location: Castricum, The Netherlands
Posts: 71
Default

Any error in php that mentions headers already being sent is usually either due to session_start() being called when output has already been sent to the browser, or because header() was called after output has already been sent. :)

Once you know that, these errors become so easy to fix :)
Reply With Quote
  #4 (permalink)  
Old 10-12-2009, 06:32 AM
DN_Angel's Avatar
Member
 
Join Date: Sep 2009
Posts: 76
Default

Good thing that you see the solution.. it's nice to know that you solve your problem all by yourself.. =p
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 11:21 AM.

Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0