RE: [PHP] best way to use session vars?

2003-10-20 Thread Ford, Mike [LSS]
On 19 October 2003 13:00, David T-G wrote:

 It seems to me that for a fast fix I could set $pw
 and other
 vars in my include file in place of registering them and then, later,
 take my time to correctly switch over to $_POST['pw'] and
 $_SESSION['pw'] everywhere.  Does that sound like a good two-step
 approach to 
 get all of
 my code back up and running the soonest?

Yes.  There's even a PHP function to help with this quick-and-dirty solution -- 
extract($_SESSION) should do what you want (see http://www.php.net/extract).

Cheers!

Mike

-
Mike Ford,  Electronic Information Services Adviser,
Learning Support Services, Learning  Information Services,
JG125, James Graham Building, Leeds Metropolitan University,
Beckett Park, LEEDS,  LS6 3QS,  United Kingdom
Email: [EMAIL PROTECTED]
Tel: +44 113 283 2600 extn 4730  Fax:  +44 113 283 3211 

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



Re: [PHP] best way to use session vars?

2003-10-20 Thread David T-G
Mike, et al --

...and then Ford, Mike   [LSS] said...
% 
% On 19 October 2003 13:00, David T-G wrote:
% 
%  It seems to me that for a fast fix I could set $pw
...
%  my code back up and running the soonest?
% 
% Yes.  There's even a PHP function to help with this quick-and-dirty solution -- 
extract($_SESSION) should do what you want (see http://www.php.net/extract).

Oooh!  Oh, cool; *now* I see how that function is useful!


% 
% Cheers!

*Very*.


% 
% Mike


Thanks!  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] best way to use session vars?

2003-10-19 Thread David T-G
Curt, et al --

...and then Curt Zirzow said...
% 
% * Thus wrote David T-G ([EMAIL PROTECTED]):
%  
%  Should I use $_SESSION for everything or should I use session_start and
%  session_register and friends instead?  Is there a clear win with either
%  one?
% 
% $_SESSION is the proper way to do it (with globals off), you will still need to call
% session_start() on each page.

Ahhh...  OK; that's the key.  So I session_start but that's all, and then
I write into $_SESSION to save it and read from $_SESSION whenever I want
its value.  And to unset a var (incorrect password entered so I want to
wipe out that entry) can I unset($_SESSION[varname])?  And, finally, do I
need session_write_close() any more?

The way I'm doing things at the moment has all of my session stuff in my
main include file, which gets called first.  It looks like

  session_name('$sname') ;
  session_start() ;
  session_register('pw') ;
  session_register('authemail') ;
  ...

and it keeps all of that session stuff out of the way of the rest of
the code, where I later just check

  if ( $pw != $passwordcom )
  {
...
  }

and such.  It seems to me that for a fast fix I could set $pw and other
vars in my include file in place of registering them and then, later,
take my time to correctly switch over to $_POST['pw'] and $_SESSION['pw']
everywhere.  Does that sound like a good two-step approach to get all of
my code back up and running the soonest?  [I won't be able to check this
today but I'll be on it tomorrow morning at 0500ET when my day starts, so
please don't think I'm just fishing for answers; I'd love to see some by
then but if not I'll forge off on my own!]


% 
% Curt


Thanks  HAND

:-D
-- 
David T-G  * There is too much animal courage in 
(play) [EMAIL PROTECTED] * society and not sufficient moral courage.
(work) [EMAIL PROTECTED]  -- Mary Baker Eddy, Science and Health
http://justpickone.org/davidtg/  Shpx gur Pbzzhavpngvbaf Qrprapl Npg!



pgp0.pgp
Description: PGP signature


Re: [PHP] best way to use session vars?

2003-10-18 Thread Curt Zirzow
* Thus wrote David T-G ([EMAIL PROTECTED]):
 Hi, all --
 
 Well, now that I have to change my code around, I suppose I should learn
 the best way, if there is one in particular, to manage sessions.
 
 Should I use $_SESSION for everything or should I use session_start and
 session_register and friends instead?  Is there a clear win with either
 one?

$_SESSION is the proper way to do it (with globals off), you will still need to call
session_start() on each page.



Curt
-- 
My PHP key is worn out

  PHP List stats since 1997: 
  http://zirzow.dyndns.org/html/mlists/

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