php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #19157 Location not working
Submitted: 2002-08-28 15:07 UTC Modified: 2002-10-21 14:48 UTC
From: shelley at databyte dot com Assigned:
Status: Not a bug Package: Session related
PHP Version: 4.2.2 OS: w2k server
Private report: No CVE-ID: None
 [2002-08-28 15:07 UTC] shelley at databyte dot com
The header("Location only works 1/3 of the time. I had the same problem on PHP 4.2.1 so I upgraded to 4.2.2 to see if it fixed the problem, and it doesn't. I'm using Zend and I tried this program without using Zend same results. The Location command only works 1/3 of the time the other times I get an CGI error msg. I need this ASAP we are working on a major project and this is holding us up.

include_once("defaults.inc");
include_once("passfunc.inc");
$tst=headers_sent();
include_once("config.inc");
include_once("conn.inc");
$tst=headers_sent();
include_once("ecom_errors.inc");
$tst=headers_sent();
	session_start();
	$sess_key=session_id();
$tst=headers_sent();	
//	$gsess_key="'".$sess_key."'";	
	$access = 'grant';
	$page_name='page1.php';
	$login='shelley';
	$HTTP_SESSION_VARS['saccess'] = $access;
	$HTTP_SESSION_VARS['susername'] = 'Shelley Jones';
	$HTTP_SESSION_VARS['suserid'] = $login;
	$HTTP_SESSION_VARS['suseris'] = 'Cust';
	$HTTP_SESSION_VARS['spage'] = $page_name;
$tst=headers_sent();
$g_url="Location:http://localhost/php/page2.php?K="."'".$sess_key."'";
redirect2($g_url);
exit;

This is the redirect function:

<?
// passfunc.inc
function redirect2($url){
header($url);
flush();
}
?>

Shelley

Patches

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-08-28 23:08 UTC] kalowsky@php.net
I'm unable to reproduce this locally.  Can you provide the simplest script to reproduce this?
 [2002-08-29 12:56 UTC] shelley at databyte dot com
I just cut and pasted this together for you. You might have to tweak this a bit to run. I'm also using ADODB for the Connection the newest Version. As you can see below. 


<?
// defaults.inc
global $timestamp;
global $Version_no;
global $fusrname;

if (!isset($ERR)){
	$ERR='';
}
if (!isset($sess_page)){
	global $sess_page;	
	$sess_page='page1.php';
}
if (!isset($page_name)){
	global $page_name;	
	$page_name="page1";
}
if (!isset($company)){
$company='tucker';
}
if (!isset($division)){
$division='tape';
}
if (!isset($$timestamp)){
	$timestamp=date('Y-m-d').time();
}
//$timestamp=strftime();
//@ini_set('track_errors', true);

include_once("passfunc.inc");
// config.inc
require_once('Smarty.class.php');
require_once('Version.inc');
include_once('ecom_errors.inc');
include_once('EncPwd.inc');
//include_once('session.inc');
include_once('ADOdb-errorpear.inc.php');
include_once('adodb.inc.php');
include_once('tohtml.inc.php');
include_once('/Date/Calc.php');
include_once('PEAR.php');
require_once('adodb-session.php');
//include_once('chkSecurity.inc');
// conn.inc
$cn = '';
$rs = '';
$cmd = '';
$server='dewolfe';
$user='ecomm';
$pwd='ecomm';
$database='flexx65';
$ADODB_FETCH_MODE = ADODB_FETCH_ASSOC;
$cn = NewADOConnection('mssql');
$cn->PConnect($server,$user,$pwd,$database);
include_once("ecom_errors.inc");
$tst=headers_sent();
	session_start();
	$sess_key=session_id();
	$tst=headers_sent();	
	$access = 'grant';
	$page_name='page1.php';
	$login='shelley';
	$HTTP_SESSION_VARS['saccess'] = $access;
	$HTTP_SESSION_VARS['susername'] = 'Shelley Jones';
	$HTTP_SESSION_VARS['suserid'] = $login;
	$HTTP_SESSION_VARS['suseris'] = 'Cust';
	$HTTP_SESSION_VARS['spage'] = $page_name;
$tst=headers_sent();
$g_url="Location:http://localhost/php/page2.php?K=".$sess_key."&L".$login;
redirect2($g_url);
exit;
?>
<? 
// passfunc.inc 
function redirect2($url){ 
header($url); 
flush(); 
} 
?> 

Shelley
 [2002-08-29 23:11 UTC] sniper@php.net
Please provide the _shortest_ possible script without any database stuff or include()'s...the one here is not very useful for us. And just for the record; header() works just fine for me on Linux/Apache. (even when using sessions)



 [2002-08-30 11:43 UTC] shelley at databyte dot com
If I take out all the includes ect. how are you going to run a comparable test? I'm using the ADODB sessions not PHP sessions functions. How are you going to know if PHP is working properly with all other products? I'm on the IIS Web Server 5.0 . I also ran additional test on an earlier Version of PHP 4.1.2 and everything was fine. However, I had this running on 4.2.1 and had the same problem as now.
I have left the Pear includes in. If you don't want it just remove the includes.

<?
// defaults.inc
global $timestamp;
global $Version_no;
global $fusrname;

if (!isset($ERR)){
	$ERR='';
}
if (!isset($sess_page)){
	global $sess_page;	
	$sess_page='page1.php';
}
if (!isset($page_name)){
	global $page_name;	
	$page_name="page1";
}
if (!isset($company)){
$company='tucker';
}
if (!isset($division)){
$division='tape';
}
if (!isset($$timestamp)){
	$timestamp=date('Y-m-d').time();
}
//$timestamp=strftime();
//@ini_set('track_errors', true);

include_once("passfunc.inc"); // redirect function
include_once('/Date/Calc.php'); // Pear function
include_once('PEAR.php'); // Pear
	session_start();
	$sess_key=session_id();
	$tst=headers_sent();	
	$access = 'grant';
	$page_name='page1.php';
	$login='shelley';
	$HTTP_SESSION_VARS['saccess'] = $access;
	$HTTP_SESSION_VARS['susername'] = 'Shelley Jones';
	$HTTP_SESSION_VARS['suserid'] = $login;
	$HTTP_SESSION_VARS['suseris'] = 'Cust';
	$HTTP_SESSION_VARS['spage'] = $page_name;
$g_url="Location:http://localhost/php/page2.php?K=".$sess_key."&L".$login;
redirect2($g_url);
exit;
?>


<? 
// passfunc.inc 
function redirect2($url){ 
header($url); 
flush(); 
} 
?>

Shelley
 [2002-09-23 07:58 UTC] sniper@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip


 [2002-09-25 11:06 UTC] shelley at databyte dot com
I sent comments on Monday and don't see them posted. I will try to re-state I tried this latest php4 and it didn't resolve the problem. I recieved several errors stating that it could find some of the dll's I checked the extensions & the dll's everything was there and the path's where setup correctly in the php.ini. I then used the extension folder from the previous install and didn't get this error but it still didn't work.

http://snaps.php.net/win32/php4-win32-latest.zip

Shelley
 [2002-09-26 16:51 UTC] omeunier at eyrolles dot com
This is a very simple script :
<?php
session_start();
echo 'foo';
header('Location: somewhere.php');
exit();
?>

Normaly it have to show 'foo' and crash beacaus of headers allready sent. It doesn't.
I experience this with PHP 4.2.0, 4.2.1, 4.2.3 on apache 1.3.26 (with modssl) on both RedHat 6.2 and Debian 3.0.
Configuration was register_globals Off
With the same configuration, I have the "good crash" under PHP 4.1.2 and decided to downgrade.
 [2002-09-29 11:11 UTC] iliaa@php.net
Please try using this CVS snapshot:

  http://snaps.php.net/php4-latest.tar.gz
 
For Windows:
 
  http://snaps.php.net/win32/php4-win32-latest.zip

Please keep in mind that since 4.2.0 release, PHP has output buffer enabled. This is what allows you to send header('Location: '); after the echo without getting any warnings.
If you want the pre 4.2.0 behaviour, turn off output buffering inside your php.ini.
 [2002-10-20 23:19 UTC] sniper@php.net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Open". Thank you.


 [2002-10-21 13:59 UTC] shelley at databyte dot com
I tried your suggestion and it did not work.

I have setup a Javascript redirect, this is working fine on every redirect situation we encounter. I'm not using the Location: at this time. We have other code which uses Javascript so the client will have to have java scripting turned on for the other Javascripting we use.
 [2002-10-21 14:48 UTC] sniper@php.net
Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions. 

Thank you for your interest in PHP.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Aug 18 21:01:28 2024 UTC