|
Posted by Rik on 08/10/07 16:45
On Fri, 10 Aug 2007 18:10:24 +0200, Scott Bryce <sbryce@scottbryce.com>
wrote:
>> My application examins $_SERVER[ 'REQUEST_URI' ] to determine which
>> page to serve.
>
> Why?
Standard practice: single 'point-of-entry' website, serving up pages as
requested in the url. Saves a whole lot of code duplication, allthough it
might decrease performance. Look at it like an index file in the root
examing GET variables and serving up different pages according to the
given values. Only, for more easily remembered urls for humans, and the
kind of urls search-engines like, the url contains a pseudo-path: the
actual path does not exists, but is handled by a script which might be
anywhere.
> If you have stored the URL of the page you want to go to in a cookie,
> you should be looking for which page to serve in that cookie.
Never store that kind of a thing in a cookie. Use a session and just a
session cookie, store data in the server-side session.
> Or are you examining $_SERVER[ 'REQUEST_URI' ] to determine what URL to
> store in the cookie? Again, why? If I have a PHP script at
> example.com/user/login, why doesn't that script know its own URL?
Because the script might not be there? It's just a script, where the
request finally ends up being processed can have very little to do with
the requested URL.
> I may be way off base here, but your approach seems odd to me.
More a difference in approach, but a very normal one.
--
Rik Wasmus
[Back to original message]
|