Jump to content

session_start() on line1 does not work


rubing

Recommended Posts

I have been wrestling with this all night and can't find an answer.  Everybody says there has to be no blank lines or white space in your script when using the session_start() command, so I eliminated all of the blanks and put it on the very first line as follows: 

 

<?php session_start();
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en"> ...[b] rest of webpage a seperate php script starts again later.[/b]

 

yet when I go to the page I still get this error:

 

 

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/rubing/public_html/days/friday/fri3.php:1) in /home/rubing/public_html/days/friday/fri3.php on line 1

 

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/rubing/public_html/days/friday/fri3.php:1) in /home/rubing/public_html/days/friday/fri3.php on line 1

Link to comment
https://forums.phpfreaks.com/topic/94487-session_start-on-line1-does-not-work/
Share on other sites

From the error message (output started at ... fri3.php:1) either there is some white-space before the first opening <?php tag OR your file is saved in UTF-8 format and the BOM (Byte Order Mark) characters at the start of the file are being output to the bowser as content. Make sure your file is save in ANSI/ASCII mode.

I just used code editor in cpanel and found the following odd characters at the very start of my file:

<?php session_start();

 

Are these UTF-8 BOM? 

 

I am using Notepad++ in windowsxp on my home machine and don't see them there.

Yes.

 

Save them with your text editor instead.

 

I just used code editor in cpanel and found the following odd characters at the very start of my file:

<?php session_start();

 

Are these UTF-8 BOM? 

 

I am using Notepad++ in windowsxp on my home machine and don't see them there.

WOW!  I'm really glad you guys were here to help me on that one.  I would've given up and been completely disgruntled otherwise.  I can't believe this wasn't pointed out in any of the books i am reading, especially since everybody's always pimping utf-8.

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.