#19991 [Bgs]: header() vs. session_register()

From: Date: Fri, 25 Oct 2002 03:13:25 +0000
Subject: #19991 [Bgs]: header() vs. session_register()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-23262@lists.php.net to get a copy of this message
ID: 19991 User updated by: ipa4-2001@lycos.com Reported By: ipa4-2001@lycos.com Status: Bogus Bug Type: HTTP related Operating System: Windows 98SE -PHP Version: 4.2.1 +PHP Version: 4.2.1. New Comment: Well, it's OK if it's so, thanks for your information! But I still didn't get the idea why I can't have session and header Location:in the same script. Does session send such a header Location: too so that the next header Location, which I called after, might confuse the browser? Thanks for your attention. Regards, mahara Previous Comments: ------------------------------------------------------------------------ [2002-10-21 16:43:14] hholzgra@php.net for the original report: you just can't have session stuff and Location: redirects in the same script, the headers interfere and confuse browsers ... not a php bug :( for the latest addition: this is something different, please verify if it also happens with session.trans_sid=0 in php.ini and create a new report for it ------------------------------------------------------------------------ [2002-10-21 11:15:14] jaco@premsoft.co.za Hi, I also experience this problem. I am running PHP 4.2.3 on FreeBSD 4.7-PRERELEASE, with Apache 1.3.27. I have tested this with IE 6.0.2600.0000, running on Windows 2000 server SP2. The following code works for me: <?php $dlfile = "./temp.zip"; header("Content-Type: application/download-script-by-hex\n"); header("Content-Disposition: attachment; filename=\"$dlfile\""); header("Content-Transfer-Encoding: binary"); ?> But, fails as soon as I add session_start(). <?php session_start(); $dlfile = "./temp.zip"; header("Content-Type: application/download-script-by-hex\n"); header("Content-Disposition: attachment; filename=\"$dlfile\""); header("Content-Transfer-Encoding: binary"); ?> Also, in lynx (FreeBSD 4.7-PRERELEASE) I can download the file, but, I get a 4 byte Ascii file, the spaces. When I remove the session_start(), I get a Ascii file that is 10 bytes bigger than the origional, the new file also filled with spaces. Am I just missing something here, or is this a bug ? Thank you. Regards Jaco van Tonder ------------------------------------------------------------------------ [2002-10-19 11:05:45] derick@php.net Thank you for taking the time to report a problem with PHP. Unfortunately you are not using a current version of PHP -- the problem might already be fixed. Please download a new PHP version from http://www.php.net/downloads.php If you are able to reproduce the bug with one of the latest versions of PHP, please change the PHP version on this bug report to the version you tested and change the status back to "Open". Again, thank you for your continued support of PHP. ------------------------------------------------------------------------ [2002-10-19 11:04:37] ipa4-2001@lycos.com I want to make the use of session in PHP (4.2.1) so I try this code... session_start(); $_SESSION['user'] = 'myname'; $_SESSION['password'] = 'mypassword'; which is similar to the following... $user = 'myname'; $password = 'mypassword'; session_start(); session_register('user'); session_register('password'); The problem comes when I add header() function so that the script become... session_start(); $_SESSION['user'] = 'myname'; $_SESSION['password'] = 'mypassword'; header('Location: http://www.mysite.info/member/index.php'); When I try this (on IE 5.5, Windows 98SE; Apache 1.3.26), it didn't take me to the page I specified above. It led to an error message "The requested URL could not be retrieved". I don't meet any solution of that so I think it's a bug. Can anyone help me explaining what's going on? ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=19991&edit=1

« previous php.bugs (#23262) next »