Re: session open failed and header() don't redirect

From: Date: Wed, 10 Oct 2001 08:18:16 +0000
Subject: Re: session open failed and header() don't redirect
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-70603@lists.php.net to get a copy of this message
Not sure about the session problem, but the problem with the header is this: You sent HTML to the browser (from html-head.inc). Th eway it works is, Headers are always sent to the browser first, then the HTML. Sending headers after some HTML would be useless even if PHP did let ya do it. =) In this case, you would need to remove the includes for header and footer (it's redirecting anyways, why bother?) =) Any time you use the Header() function, double-check and make sure nowhere else in the script is data being sent to the browser. =) - Tim Web user wrote: > Hi, > There are still problems with session and header(); > Please give me some advice. > Thank you! > Mike > > System: PHP4.06 + Apache 1.3.20 Win32 + Win98 (the session configurations > are default in php.ini) > when the 1.php is running, the IE shows 2 errors as below: > > Warning: open(/tmp\sess_5176646ce5a800db9101970b80d507f6, O_RDWR) failed: m > (2) in c:\program files\apache group\apache\htdocs\web1\1.php on line 2 > > Warning: Cannot add header information - headers already sent by (output > started at c:\program files\apache group\apache\htdocs\web1\1.php:2) in > c:\program files\apache group\apache\htdocs\web1\1.php on line 6 > > ------------------------------- > The scripts of 1.php: (1.php and 2.php are under the same base directory) > <? > session_start(); > require("html-head.inc"); > $name="user"; > session_register("name"); > header("Location: 2.php"); /* let the IE automatically turn to the 2.php */ > require("html-foot.inc"); > ?> > ------------------------------- > The scripts of html-head.inc: > <html> > <head> > <meta http-equiv="Content-Type" content="text/html; > charset=ISO-8859-1"> > <title>page title</title> > </head> > <body> > > ----- > The scripts of html-foot.inc: > </body> > </html> > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net -- - Tim PHP Galaxy: http://www.phpgalaxy.com/ The LavaWarp Engine: http://www.phpgalaxy.com/engine.php3 BitSearch: http://www.phpgalaxy.com/bitsearch.php3 MetaWarp: http://www.phpgalaxy.com/metawarp.php3 PhotoRate: http://www.phpgalaxy.com/photorate.php3 Earn $10 per order selling these scripts on your site! http://www.phpgalaxy.com/aff/

« previous php.general (#70603) next »