RE: losing my session variables

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

 



> -----Original Message-----
> From: Peter Beckman [mailto:beckman@purplecow.com]
> Sent: 30 October 2002 04:09
> To: Seabird
> Cc: php-db@lists.php.net
> Subject: Re:  losing my session variables
> 
> 
> Put "session_start()" somewhere in your code.

.. but make sure that "somewhere" is before you do any real output to your page!

> $_SESSION isn't set until you "start" your session.
> 
> And don't set session variables by $_SESSION[foo] = bar;
> 
> DO this:
> 
> $foo = bar;
> session_register("foo");
> 
> Much better.

No -- this is fraught with problems in current releases of PHP (most, if not all, of which will be fixed in 4.3).  Most particularly, the following caution appears at http://www.php.net/manual/en/ref.session.php:

  "If you are using $_SESSION and disable register_globals, do not use session_register(), session_is_registered() and session_unregister(), if your scripts shall work in PHP 4.2 and earlier."

Since the default for 4.2.x is register_globals=off, this is a very pertinent warning!

Even with register_globals=on, there are other problems which make it best to stick to manipulating the values in $_SESSION directly, rather than using the "equivalent" global variables.

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: m.ford@lmu.ac.uk
Tel: +44 113 283 2600 extn 4730      Fax:  +44 113 283 3211 

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux