php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #27480 session problem with session.start()
Submitted: 2004-03-03 07:56 UTC Modified: 2004-04-08 11:07 UTC
Votes:3
Avg. Score:3.3 ± 1.7
Reproduced:0 of 1 (0.0%)
From: ricardo at aganp dot go dot gov dot br Assigned:
Status: Not a bug Package: Session related
PHP Version: Irrelevant OS: SUSE 8
Private report: No CVE-ID: None
 [2004-03-03 07:56 UTC] ricardo at aganp dot go dot gov dot br
Description:
------------
When session.start() PHP document is loaded at the first time it?s necessary to refresh the page to view the contents. We are using the PHP version 4.0.4pl1 before this new version 4.2.2 and this problem not happened. There is some BUG on this 4.2.2 PHP Version about session? How can I solve my problem?




Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2004-03-03 08:04 UTC] derick@php.net
Also, upgrade to atleast php 4.3.4 first.
 [2004-03-03 09:35 UTC] ricardo at aganp dot go dot gov dot br
I have a PHP file name top.php where I open the postgre conection and start the session. Another php file name button.php where I close my postgre conection. This two files are put into all my php files. The first one, top.php, on the top of my index.php and the button.php on button, like this:
top.php
<? pg_connect($param)
   session_start();
?>

button.php
<? pg_close($con) ?>

index.php
<? include "top.php";
   HTML
   include "button.php";
   
Every the first time a load this index.php file, I need to refresh this page and all the contents of my html are show. If I do not refresh the page I got a blank page.
However, if I delete the session_start() the page works normally.

It?s very difficult to change the php version here, whe are a big corporation. But, as I said we have an older version 4.0.4pl1 at another computer end it works perfect.
 [2004-03-06 14:05 UTC] iliaa@php.net
Are you using output buffering and can you verify the error 
with latest CVS? 
 [2004-03-08 09:12 UTC] ricardo at aganp dot go dot gov dot br
we don't compile php by source. We're using the RPM version that cames with operacional system. It's very difficult to compile a source version because we're using 64 bits and we need to remake many linkings.
 [2004-03-23 15:15 UTC] ricardo at aganp dot go dot gov dot br
I did not decide the problem yeat. Can anyone help me?
 [2004-03-29 04:40 UTC] unknown at simplemachines dot org
I believe this is bogus.  I've seen this problem before, and it has to do with output buffering.

This will ALWAYS happen if you choose to start ob_gzhandler after session_start().  Instead, session_start() should be called afterward.

Why?  It's actually quite simple.  Since session_start() sends headers, it messes with output buffering... and makes it so that gzipped output is not sent to the client properly.

Are you absolutely sure you're not using any output buffering - whether in php.ini or in your scripts?

-[Unknown]
 [2004-03-29 14:41 UTC] ricardo at aganp dot go dot gov dot br
I'm not using ob_gzhandler. In php.ini output_buffering is set to "no value" "no value". I put session_start() before <html><head>. Is the first command on the page.
 [2004-04-08 11:07 UTC] sniper@php.net
Too old PHP version. (and sessions work just fine with properly setup system and correct PHP code/logic)

 [2004-05-16 00:29 UTC] pjurenc at quorum dot pl
Seems I've got the same problem as Ricardo. Each time I load the page (including session_start() at the top of the script) for the first time, I need to refresh it. When I remove session_start() it works fine. The PHP version is 4.3.6 (on ver 4.1.1 it works fine).
What is strange: having 2 very similar script one works, another doesn't. What I found while trying to resolve the problem: outputs by command like echo "test" work but an ordinary HTML code doesn't. I need to solve this as soon as possible.
 [2004-05-16 16:18 UTC] pjurenc at quorum dot pl
Continuing my problem, I thought it would be helpfull include some of my scripts. The problem is with last quoted script forgotpass.php. The one which is not displayed unles refresh is done in browser. After removing line with session_starts() page is displayed. 

---- file: index.php
<?
session_start();
$_SESSION["sitevisitor"]="ok";

/* some scripting, HTML code */

<a href="javascript;" onClick="window.open('login.php',....);">Login</a>

/* some scripting, HTML code */
?>

---- file: login.php
<?
session_start();
if(!isset($_SESSION["sitevisitor"]) || $_SESSION["sitevisitor"]<>"ok") die('Access deni');

/* some scripting, HTML code */

/* both links below open in current active window, same as login.php was */
<a href="forgotpass.php">Forgot password ?</a>
<a href="regnewuser.php">Register a new user? </a>

/* some scripting, HTML code */
?>

---- file: forgotpass.php, the script I've got the problem displaying
<?
session_start();
if(!isset($_SESSION["sitevisitor"]) || $_SESSION["sitevisitor"]<>"ok") die('Access deni');
/* some scripting */
echo "this text is displayed";
?>
<HTML>
....
<BODY>
nothing from here is displayed unless Refresh is done in WebBrowser
Whats more, the WebBrowser's location/address bar contains the old index.php URL
</BODY>
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat May 04 16:01:31 2024 UTC