Connecting Tech Pros Worldwide Help | Site Map

session_start() error

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 17th, 2005, 12:55 PM
y_oda2002
Guest
 
Posts: n/a
Default session_start() error

I keep getting an error that says this

Warning: session_start(): Cannot send session cache limiter - header
already sent (output started at c:\program files\easyphp1-8\www\th
site\adminlogin.php:3) in c:\program files\easyphp1-8\www\th
site\access.inc.php on line

Does anyone know what it means? I am trying to create a account logi
and that warning comes up... Nothing bad happens. If anything doe
anyone know how to suppress php from showing the warning? though I'
rather figure out how to fix i

Thanks

Nic
http://eye.cc -php- web design

  #2  
Old July 17th, 2005, 12:55 PM
Berislav Lopac
Guest
 
Posts: n/a
Default Re: session_start() error

y_oda2002 wrote:[color=blue]
> I keep getting an error that says this:
>
> Warning: session_start(): Cannot send session cache limiter - headers
> already sent (output started at c:\program files\easyphp1-8\www\the
> site\adminlogin.php:3) in c:\program files\easyphp1-8\www\the
> site\access.inc.php on line 5
>
> Does anyone know what it means?[/color]

You have to put session_start *before* any other output from the script, ie.
before any echo, print or similar.

Berislav


  #3  
Old July 17th, 2005, 12:55 PM
Andy Hassall
Guest
 
Posts: n/a
Default Re: session_start() error

On Sat, 30 Apr 2005 09:01:10 GMT, nrhodes@thiel-dot-edu.no-spam.invalid
(y_oda2002) wrote:
[color=blue]
>I keep getting an error that says this:
>
>Warning: session_start(): Cannot send session cache limiter - headers
>already sent (output started at c:\program files\easyphp1-8\www\the
>site\adminlogin.php:3)[/color]

OK, what's in adminlog.php line 3?
[color=blue]
>in c:\program files\easyphp1-8\www\thesite\access.inc.php on line 5
>
>Does anyone know what it means?[/color]

It means you're trying to start a session, so PHP is trying to send a cookie
and a cache limiter header, but you've already output some content - HTTP
headers can only be sent before any other content.
[color=blue]
>I am trying to create a account login
>and that warning comes up... Nothing bad happens. If anything does
>anyone know how to suppress php from showing the warning?[/color]

Don't suppress this - it's actually a bit more serious than just a warning as
it'll be screwing up your sessions.
[color=blue]
>though I'd rather figure out how to fix it[/color]

Yep, much better.

--
Andy Hassall / <andy@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
  #4  
Old July 17th, 2005, 01:16 PM
y_oda2002
Guest
 
Posts: n/a
Default re:session_start() error

Thanks for trying to help...

However I still can't figure out the problem....

I keep getting the same error...

Here is what I am doing...

I have some structured code... include files....
I am trying to create a user login where each page knows the user is
or isnt logged in....
However whenever I refrence the file with this code (always included
at the beginning of the file)...

session_start();

function loggedIn()
{
return isset($_SESSION['authorized']);
}

It throws that error....
Should I only use session_start() once when the user enters the main
page?
It seems that the first page to start the session is fine and
continues to be fine evening when going to it from a page with the
error....
Does anyone know of anything on the web about sessions that would be
able to help me?

Thanks again for your time..
It's greatly appreciated....

Nick
http://eye.cc -php- web design
  #5  
Old July 17th, 2005, 01:16 PM
Mick Sharpe
Guest
 
Posts: n/a
Default Re: re:session_start() error

This may be a bug in PHP. I found that session_start() does not work if
called from inside a function - you have to call it from top-level code.
Also, you need to call it before you do anything else. HTH :-)


  #6  
Old July 17th, 2005, 01:16 PM
Angelos
Guest
 
Posts: n/a
Default Re: re:session_start() error


"Mick Sharpe" <mick.sharpe@btinternet.com> wrote in message
news:d6pj7i$457$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...[color=blue]
> This may be a bug in PHP. I found that session_start() does not work if
> called from inside a function - you have to call it from top-level code.
> Also, you need to call it before you do anything else. HTH :-)[/color]

I don't think so... I can start a session later in my code inside a switch
case: statement for example...
You might be wrong


  #7  
Old July 17th, 2005, 01:17 PM
Philip Olson
Guest
 
Posts: n/a
Default Re: session_start() error

That is unrelated, a switch does not give output. echo 'foo'; is
output. if () is not. Regarding the inability to use session_start()
inside a user defined function, I don't see why this would be a
problem. I'm guessing it was something else.

The key here is output. Headers already sent = output already sent. If
your include file (access.inc.php) has a space after the closing ?>
(line 5ish), that is output. I'm guessing this is the case. It's common
to leave off the closing ?> within include files as to eliminate this
potential problem.

  #8  
Old July 17th, 2005, 01:17 PM
Mick Sharpe
Guest
 
Posts: n/a
Default Re: session_start() error

That would explain nicely the problems I experienced - thanks for that :-)


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.