473,624 Members | 2,150 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2023
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\adminlogi n.php:3)
OK, what's in adminlog.php line 3?
in c:\program files\easyphp1-8\www\thesite\a ccess.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.andyhsoftwa re.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*********@bt internet.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
2895
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 session_start();
2
1925
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. Namely... I'm working on someone else's code who has used sessions - In their main login page, they do not use session_start() but instead, just write directly to the $_SESSION super global array variable. This seems to work - however on some later...
3
2207
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 client. MySQL works perfectly. I have created and queried databases with no problem. Apachie 2 appears to work with no problem. I can call up web pages in the expected maner.
8
2227
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 I set them afterwards?
4
5907
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 using windows authentication. On a few pages I get guest and then the user who is loged into the computer. I am writing user information to my session and do not want it writen 8 times.
4
6650
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 wanted to redirect to an error page. But, this doesn't seem to work. So, another question is, if an exception is thrown and caught in a catch block in Application_Start and/or Session_Start, what do we or can we do with it?
19
7917
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 limiter - headers already sent in /home/httpd/vhosts/monkeyclaus.org/httpdocs/media/audio/pdsIncludes/CommandStartSession.php on line 14
2
1840
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 can not stop the error in my script. The session_start() is the first thing that happens before any Headers are created. Any one have any suggestions. Include the start of the code that uses the session var. Warning: session_start(): Cannot...
6
1962
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', TRUE) before session_start() do I see anything, it just plain dies. I used LiveHTTPHeaders to verify that I am getting a 200 OK response, thus everything seems OK except that it's dying on session_start(). Sometimes.
4
5933
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, however and am really struggling with managing sessions in PHP, based on my experiences with managing sessions in ASP. 99.9% of the feedback I have seen when dealing with the errors has referred to having whitespace before the <?php or after the...
0
8173
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8679
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8621
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8475
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7159
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6110
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5563
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4174
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1482
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.