Ask a Question related to PHP Development, Design and Development.
-
Agelmar #1
Re: session_start()
Ian.H [dS] wrote:
Just one clarification for the original poster, as I think this still might> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Whilst lounging around on 11 Jul 2003 07:51:58 -0700,
> [email]skywalker2070@hotmail.com[/email] (sky2070) amazingly managed to produce the
> following with their Etch-A-Sketch:
>>>> i am trying to session_start() function in my code but the server
>> return
>>
>> Warning: session_start() [function.session-start]: Cannot send
>> session cookie - headers already sent by (output started at
>> C:\Program
>> Files\Apache Group\Apache2\htdocs\sessionstart.php:9) in C:\Program
>> Files\Apache Group\Apache2\htdocs\sessionstart.php on line 11
>>
>> Warning: session_start() [function.session-start]: Cannot send
>> session cache limiter - headers already sent (output started at
>> C:\Program Files\Apache Group\Apache2\htdocs\sessionstart.php:9) in
>> C:\Program Files\Apache Group\Apache2\htdocs\sessionstart.php on
>> line 11
>>
>> can anyone point out where is the error?
>
> Yes.. on line 11 ;)
>
> On a more serious note.. session_start() should be the first call in
> your script (well above any output ever occurs).. hence you get the
> "headers alrady sent" as by the time you're calling session_start()
> (which is a header value), it's already displaying the "body" =)
>
>
>
> Regards,
>
> Ian
>
> -----BEGIN PGP SIGNATURE-----
> Version: PGP 8.0
>
> iQA/AwUBPw7QrWfqtj251CDhEQKhYgCggA4PnS8z16i0B1e9dc5Tb7 v3Ip4An2pl
> tOQsMnFzbOkkEBfejIUKMSNX
> =yQJy
> -----END PGP SIGNATURE-----
be semi-unclear to him. (Had he understood the manual he would not be asking
this question, so obviously a very detailed answer is required since the
manual entry for session_start() is VERY clear.)
session_start() must come before *any* output. That means that if your file
is like this:
<start of file>
<blank line>
<?php
session_start();
....
you've got a problem. The blank line starts the output, and sends headers.
session_start() must come before any and all output. (It need not
*necessarily* be the first call, but this is usually a good practice, as
this will ensure there is no output before it..) So use:
<start of file>
<?php
session_start();
....
and you should have no problems.
// Ian Fette
Agelmar Guest
-
Help with session_start()
Hi. I was tring to start a session my web page and tried using the session_start(). However i keep gettin the warning: Warning: session_start()... -
Session_Start not firing
I'm workinbg in Visual Studio 2003. I'm experimenting with creating a session variable, and from all I can gather. the Session_Start event is not... -
Classes and session_start()
Hello there! I'm building a php system where I can put images in a zipfile and download it. I found some code to do this and created zip.php, a... -
session_start() problem
* Thus wrote Jeff McKeon (com): Not related to your problem but: > session_regisister("userid", "userpassword"); spelling ~~~^^^^^^^^^^ -
About Session_Start() with different Browser
Hi all, I am new to php. At first, I wrote a php script to generate a pdf file from a tex file and load that pdf file to the browser by call a... -
cwepema #2
session_start()
Hi,
I am working on a project where I need global variables to pass through
some files.
To achieve this, I am using session_start()in all files where global
vars are needed..
I am aware of the fact that I have to omit every output before I use
session_start().
However, still I receive error messages like:
" Warning: session_start(): Cannot send session cookie - headers already
sent by (output started at/home/www/123.freefronthost.com/header.html:9)
in /home/www/123.freefronthost.com/extrins.php on line 2"
and:
"Warning: session_start(): Cannot send session cache limiter - headers
already sent (output started at
/home/www/123.freefronthost.com/header.html:9) in
/home/www/123.freefronthost.com/extrins.php on line 2"
Scripts that need session_start() to assign values to the global vars,
always look like this (in 'header.html' I've included the html header info):
01 <?php
02 session_start();
03 $MyGlobalVar=$_SESSION['MyGlobalVar'];
04 include('header.html');
05 include('somethingelse.inc');
...
nn ?>
What should I do to fix the errors/warnings?
Thanks very much in advance!
Best regards, Kees Epema
cwepema Guest
-
Steve #3
Re: session_start()
Buffer all output with ob_start() / ob_get_contents() and write it to a
file. Then download the file to see exactly what is written to the
browser.
---
Steve
Steve Guest
-
Michael #4
Re: session_start()
.oO(cwepema)
What is on the above mentioned lines?
Micha
Michael Guest
-
Colin #5
Re: session_start()
Steve wrote:
....won't solve problem if there is an auto-prepend set in the ini file.
C.
Colin Guest
-
Steve #6
Re: session_start()
X-No-Archive: yes
file.
OK, but it was not intended to solve the problem but to add
information.
If phpinfo() does says there's an auto_prepend_file, well there's an
ideal place to stick an ob_start() 8-)
---
Steve
Steve Guest
-
cwepema #7
Re: session_start()
treefrog wrote:
>
>
> Make sure there is absolutely no white space before the initial <? or <?php
> tag. Even a single space messes it up. To debug it, look at the HTML source
> and see what is before your first error message. Chances are though, that
> it's the phantom space.
>
> Nathan
>
>[/ref]
Thanks to you all!
After all the problem was solved by something stupid simple:
The form that generates the POST vars, had to check validity of a date.
Therefore I made an include (chkDate.php)in which I also included the
'header.html' file.
After chkDate.php the actual page ('extrins.php') showed up, with the
error messages as initially described.
I deleted the ínclude('header.html') from the 'chkDate.php' file
and...problem solved.
Sorry for disturbing you all, but thanks for your help! I hope somebody
benefits anyhow from the problem!
Best regards, Kees Epema
cwepema Guest
-
treefrog #8
Re: session_start()
"cwepema" <nl> wrote in message
news:qCXGd.8253$lga...
Make sure there is absolutely no white space before the initial <? or <?php
tag. Even a single space messes it up. To debug it, look at the HTML source
and see what is before your first error message. Chances are though, that
it's the phantom space.
Nathan
treefrog Guest



Reply With Quote

