Re: $_SESSION and header()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sun, June 26, 2005 7:33 am, Alessandro Rosa said:
> (a) : After saving a couple of data into two $_SESSION variables from a
> form,
> (b) : I used the header() function to redirect the browser to
> (c) : display another page.

(c) needs <?php session_start();?> at the top, just like (a) and (b) and
(z) for any other page you want to use your session data.

Also, *WHY* redirect the browser and chew up an HTTP connection and make
your application twice as slow?

Plus, with the session_start() in there, you're going to duplicate all the
effort you've already gone to to build up the session data structure
(overhead).

At that point in your script, you could just "include" (c) and be done
with it.

It's a heck of a lot easier to debug without feeling like you're the
pinball in a fast-paced game of HTTP redirects, imho.

You also make life easier on cURL and other programmatic access of your
site, if you don't force them to play "follow the bouncing ball" to track
down what they asked for.  Just give it to them already. :-)

I played with header("Location: ") in my early PHP days, and stopped using
it rather quickly, unless I actually have a URL I want to maintain for the
search engines for awhile, but the document has actually moved.

Just because the re-direct works doesn't make it the best answer.

Others on this list just LOVE to have a bunch of header("Location: ")
statements in their PHP code, so you are not alone.

Just something to think about. :-)

-- 
Like Music?
http://l-i-e.com/artists.htm


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux