Re: [PHP] Re: Problem with sessions.(Again Sorry :)

2002-07-21 Thread Richard Lynch

 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. :-)

-- 
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




RE: [PHP] Re: Problem with sessions.(Again Sorry :)

2002-07-21 Thread John Holmes

 From: Richard Lynch [mailto:[EMAIL PROTECTED]]
 
  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...


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