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
Share on other sites

1.  is the above code from script fri3.php?  If it's called from another script, it won't work ... depending...

 

Are you in Windows?  Some text editors have characters that are not human readable.  Try using notepad and resaving.

Link to comment
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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.