472,804 Members | 937 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,804 software developers and data experts.

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
Jul 17 '05 #1
7 1990
y_oda2002 wrote:
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?


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

Berislav
Jul 17 '05 #2
On Sat, 30 Apr 2005 09:01:10 GMT, nr*****@thiel-dot-edu.no-spam.invalid
(y_oda2002) wrote:
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)
OK, what's in adminlog.php line 3?
in c:\program files\easyphp1-8\www\thesite\access.inc.php on line 5

Does anyone know what it means?
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.
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?
Don't suppress this - it's actually a bit more serious than just a warning as
it'll be screwing up your sessions.
though I'd rather figure out how to fix it


Yep, much better.

--
Andy Hassall / <an**@andyh.co.uk> / <http://www.andyh.co.uk>
<http://www.andyhsoftware.co.uk/space> Space: disk usage analysis tool
Jul 17 '05 #3
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
Jul 17 '05 #4
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 :-)
Jul 17 '05 #5

"Mick Sharpe" <mi*********@btinternet.com> wrote in message
news:d6**********@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com...
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 :-)


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
Jul 17 '05 #6
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.

Jul 17 '05 #7
That would explain nicely the problems I experienced - thanks for that :-)
Jul 17 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Florence HENRY | last post by:
Hello, I've searched about my problem on google before posting, but I didn't find anything relevant... I have a problem with session_start. Here is my code : <html> <head> <?php...
2
by: Reply-Via-Newsgroup Thanks | last post by:
Folks, I consider myself a reasonably strong PHP programmer, but I've not used sessions before (I've used cookies instead) and I'd appreciate it if someone could confirm something for me. ...
3
by: Trogdor | last post by:
I set up a server on an AMD 650 machine running gentoo linux. I installed Apachie 2, MySQL 4.1 and PHP 4.3.11 I use another computer on my local net (192.168.0.x) to access the server as a...
8
by: lkrubner | last post by:
I was trying to set a cookie before I called session_start() and it was giving me an error. But isn't sessions really just a cookie? Why would it matter if I sent a cookie before session_start? Can...
4
by: Curious George | last post by:
I have a frameset with multiple aspx pages whithin it. I lauch the page and notice that it triggers many session_start events. In fact I knotice multiple events for the same page. I am also...
4
by: csn | last post by:
Is it possible to have a Response.Redirect in Global.asax in the Application_Start and Session_Start events? We have code in both events, with try-catch blocks, and if an exception is caught, we...
19
by: lawrence k | last post by:
How can I find out where my script is outputting to the screen for the first time? My error logs are full of stuff like this: PHP Warning: session_start(): Cannot send session cache...
2
by: IchBin | last post by:
I am getting the error message below when ever I try to start my script on two different servers. I am not getting any errors off of my PC. I have looked around and found the answer a simple one. I...
6
by: comp.lang.php | last post by:
I am using session_start() on index.php and for some reason sometimes it'll fail. No warnings, no errors, no notices, not even after prepending error_reporting(E_ALL) and ini_set('display_errors',...
4
by: three-eight-hotel | last post by:
I'm somewhat of a newbie to PHP coding, but have developed a site using the technology, and have been pleasantly surprised by the capabilities offered. I am more comfortable in the ASP world,...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.