RE: [PHP] Re: Problem with sessions.(Again Sorry :)
| From: | John Holmes | Date: | Sun, 21 Jul 2002 22:49:39 +0000 |
| Subject: | RE: [PHP] Re: Problem with sessions.(Again Sorry :) | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108763@lists.php.net to get a copy of this message | ||
> From: Richard Lynch [mailto:rich@phpbootcamp.com]
>
> >> Don't cram things into $_SESSION. Use this:
> >>
> >> session_register('uid');
> >> global $uid;
> >> $uid = $uinfo[0];
> >
> >With PHP 4.2, you don't have to use session_register. You can do it
> >exactly like the OP is. I do it all the time. Whether that is a
> >"feature" or a bug, I don't know.
>
> It happens to work because that happens to be how Sessions are
implemented
> this week.
>
>
> Programming 101:
> Rule #27: Relying on implementation minutia instead of documented
> functions
> is just a Bad Idea (tm).
>
>
> Use the functions that are documented to work. Anything else is a
HACK
> and
> subject to break without notice.
>
> In PHP 4.3 or 5.0 or 7.3.1, when it *DOESN'T* work anymore and you
have a
> zillion lines of code cramming junk into $_SESSION scattered all
through
> your application, don't come crying to me. :-)
Always a good method to follow, but the manual says you can use the
$_SESSION method I gave. There is no need to use session_register() or
the like. I would imagine that the older method would be depreciated
eventually. It's a whole lot easier to just treat sessions like a
variable without that whole register/unregister stuff.
The manual actually cautions against using session_register/unregister
if register_globals is OFF.
http://www.php.net/manual/en/ref.session.php
---John Holmes...