473,378 Members | 1,407 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 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 2008
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,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.