php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #16807 Sessions not working
Submitted: 2002-04-24 16:21 UTC Modified: 2002-05-30 06:50 UTC
Votes:3
Avg. Score:5.0 ± 0.0
Reproduced:2 of 2 (100.0%)
Same Version:2 (100.0%)
Same OS:2 (100.0%)
From: martin_jones at bigfoot dot com Assigned:
Status: Closed Package: Session related
PHP Version: 4.2.0 OS: Windows 2000 SP2
Private report: No CVE-ID: None
 [2002-04-24 16:21 UTC] martin_jones at bigfoot dot com
When running PHP 4.2.0 on Windows 2000, IIS 5, the following code causes problems:

<?php
  session_start();
?>

I get the message:

Warning: Cannot send session cache limiter - headers already sent in D:\Development\test.php on line 2
PHP Warning:  Cannot send session cookie - headers already sent in D:\Development\test.php on line 2
PHP Warning:  Cannot send session cache limiter - headers already sent in D:\Development\test.php on line 2

It appears that sessions are still not working (they weren't working in 4.1.2 either)

--
Martin

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-04-24 19:15 UTC] yohgaki@php.net
The bug system is not the appropriate forum for asking support
questions. For a list of a range of more appropriate places to ask
for help using PHP, please visit http://www.php.net/support.php
 [2002-04-25 02:04 UTC] martin_jones at bigfoot dot com
I wasn't aware that this was a support question.

The session_start function used to work fine. Now I get the warnings as stated above.

I have looked at the support and the only things I could see was about not putting anything before the session_start. In this case, I have tried the following:

<?php
session_start();
?>

and I still get the warnings. These three lines are the only things in the script. There is no HTML above it.

Since this used to work, I disagree that it is a bogus issue and feel that it should still be a bug.
 [2002-04-25 03:26 UTC] yohgaki@php.net
Ok. 
You really have 3 line script that causes this error message.
What is your session ini setting?

 [2002-04-25 03:27 UTC] yohgaki@php.net
And output bufferring setting?
(zlib.output_compression and output_buffer)
 [2002-04-25 03:39 UTC] mfischer@php.net
And you do not have any auto_prepend stuff in your ini file, anything which might do output before your script gets actually executed (also no whitespaces) ?
 [2002-04-25 04:00 UTC] martin_jones at bigfoot dot com
My ini file is the php.ini-recommended

The session stuff is:
session.save_handler = files
session.save_path = c:\winnt\temp  (tried c:/winnt/temp too)
session.use.cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session_cookie_domain =
session.serialize_handler = php
session_gc_probability = 1
session.gc_maxfiletime = 1440
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 1

output_buffering = 4096
output_handler =

zlib.output_compression = Off

auto_prepend_file = 
auto_append_file =

I hope this is enough info. As I say, it is the recommended ini file with a few minor changes.
 [2002-04-30 04:48 UTC] renato at ostorero dot it
I'v got the same problem here.
Same configuration W2K SP2 IIS5 same recomended php.ini file.

When a script calls for:
session_start or setcookie  
like Jelsoft vBulletin nothing happen.
The same things for all my scripts.
 [2002-04-30 05:29 UTC] renato at ostorero dot it
Found solution here:
http://bugs.php.net/bug.php?id=16839
Thx

Renato
 [2002-04-30 14:27 UTC] martin_jones at bigfoot dot com
Can someone please fix this, since it is not a configuration problem.
 [2002-04-30 16:45 UTC] martin_jones at bigfoot dot com
The 'solution' above is not valid for this case.

PHP should not generate the 'headers already sent' message at all in this case.
 [2002-05-01 20:24 UTC] chris at dvdplaza dot com dot au
I'm having a similar issue - every since switching to PHP 4.2 I've got sh#tloads of viewers reporting login problems to our forums (vBulletin), they keep getting prompted to login.  Weird part is it's not everyone, I and others have no problems at all.  Reverting back to PHP 4.1.x solves it, upgrading to PHP 4.2 brings it back.

register_globals is ON
 [2002-05-03 23:52 UTC] yohgaki@php.net
martin_jones@bigfoot.com

report is not about register globals issue. Please do not add any more comments about register globals...
 [2002-05-03 23:53 UTC] yohgaki@php.net
s/martin_jones@bigfoot.com/other mail addresses who comment on this/
 [2002-05-05 18:23 UTC] dht1 at totalise dot co dot uk
The error I receive (again, 4.2.0, IIS, and Win 2k) is that it is unable to open the session folder.

May or may not be related, but I'm also experiencing problems with POST variables.

David
 [2002-05-06 20:31 UTC] bs_php at infeer dot com
Please check following:
I hade the same error because of spaces (or CR or TAB) *befor* the first use of <?php  !

Did you check that?
 [2002-05-15 05:10 UTC] keithauyeung at proactive dot com dot hk
I think the following should help.
before the statement "<?php", is there any blank line above it?If yes, delete the blank line and I think the problem will be solved. Hope this help!!
 [2002-05-15 08:30 UTC] martin_jones at bigfoot dot com
There are no blank lines in the script. The first line is <?php

Anyway - with the release of 4.2.1, this problem no longer occurs on my system. The problem appears to be fixed and this bug can be closed.
 [2002-05-28 19:36 UTC] toth_andor at hotmail dot com
funnily enough
when i turned register globals OFF
everything was allright

and i could reach all session vars
through the HTTP_SESSION_VARS array

but i can't access register globals here at this web server
since i only have phpmyadmin

what should be done when register globals is on
 [2002-05-30 06:50 UTC] mfischer@php.net
Original reporter said it's fixed in 4.2.1, closing.
 [2002-08-27 06:38 UTC] vvhotk at mail dot bg
It's not only if there's a empty line before <?php
I've got a line importing a .css file and when I moveed it - the problem went away :-)
 [2004-06-02 15:58 UTC] jteik at yahoo dot com
the problem is that your php file've saved as "UTF-8" type. you can check this by viewing your file with some HEX file edit tool. and as you'll see, before the first char of your php code file (maybe "<" of "<?php") is another char - the filetype-char (2 bytes) of "UTF-8" filetype. OMG! it'll be the HTML text printed before your code and kicks the page's headers out.

to fix it, u need to copy all your php code and paste it into Notepad, then, u save the file as "ANSI" filetype.

u'll fix the problem. but another have caused, it's u can't use other languages (or fonts) base on "UTF-8" like Vietnamese, right? hehe, but i know u can fix it easy.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 06:01:29 2024 UTC