* Thus wrote Ow Mun Heng ([EMAIL PROTECTED]):
> Hi Curt,
>
> I'm confused..
I'll try to clear this up for you. I'm going to see if I can get the
documentation on the web site fixed also. It is rather confusing.
There appears to be two ways to do sessions:
'---------------------------
Style 1 (discuraged use):
'---------------------------
session_start(); // start the session
session_register('var'); // register global $var as session var
$var = $row['var']; // assign global $var a value
// now the session will save the value
// that is inside $var as long as its global
// scoped
// check to see if $var is registered with the session handler
if ( session_is_registered('var') ) {
// session is registered but doesn't gaurentee
// that a value is inside of it.
// so check to see if there is a value
if (isset($var)) {
// yes we have a value
} else {
// no value assigned
}
} else {
// session variable $var is not registered so the
// variable $var will not be saved in the session
}
session_unregister('var'); // Now var will not be saved in the
// session
'---------------------------
Style 2 (prefered method):
'---------------------------
session_start(); // start the session
$_SESSION['var'] = $row['var']; // set the session value
// any time you need to access this
// value you need to reference it
// through $_SESSION['var']
// check to see if session 'var' is in the session
if(isset($_SESSION['var']) ) {
// yes, so pull it out and do stuff
$var = $_SESSION['var'];
// do stuff...
} else {
// no, there is no $_SESSION['var']
// and will not be saved in session.
}
unset($SESSION['var']); // Now var will not be saved in the
// session
HTH,
Curt
--
"I used to think I was indecisive, but now I'm not so sure."
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php