Re: Some SESSION Vars not Registering

From: Date: Wed, 23 Jul 2003 13:13:49 +0000
Subject: Re: Some SESSION Vars not Registering
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-156438@lists.php.net to get a copy of this message
* Thus wrote Ow Mun Heng (ow.mun.heng@wdc.com): > I'm new but.. aren't you also supposed to register the session?? > > My code .. > > session_start(); > session_register('username'); > $_SESSION['username'] = $row['username']; > session_register('user_id'); > $_SESSION['user_id'] = $row['user_id']; > session_register('access_level'); > $_SESSION['access_level'] = $row['access_level']; No that is incorrect. <snip session_register()> CAUTION: If you are using $_SESSION (or $HTTP_SESSION_VARS), do not use session_register(), session_is_registered(), and session_unregister(). </snip> What happens if you register session_register('username') is that the $_SESSION['username'] namespace is dedicated to the global variable $username. So, if in your script after your block of code, you use the variable $username (global scoped) then your $row['username'] value you assigned in $_SESSION['username'] is gone. Curt -- "I used to think I was indecisive, but now I'm not so sure."

« previous php.general (#156438) next »