Re: Auth and user permission levels
| From: | Markus Wolff | Date: | Sat, 08 Feb 2003 12:46:37 +0000 |
| Subject: | Re: Auth and user permission levels | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-3670@lists.php.net to get a copy of this message | ||
On Fri, 7 Feb 2003 23:46:12 +0100
"Michael Jansen" <mj@weltennetz.de> wrote:
>
> "Markus Wolff" wrote:
>
> > I'd like to use Auth for allowing access to different
> > sections website >
> Hi Markus,
> I have added some attributes to the auth table like realname,
> userlevel etc. Then I wrote a function 'setAdditionalSessionVars()'
> which get these Atributes from the table and register as SessionVars.
> ...
> function setAdditionalSessionVars(){
>
> $db = DB::connect($this->dsn);
>
> if (isset ( $_SESSION['auth']['username'] )
>
>
> $username = $_SESSION['auth']['username'];
>
> $query = "SELECT vorname , nachname, hdz , userlevel, email ";
> $query .= "FROM auth WHERE username = '$username' ";
>
> $result = $db->getRow($query,DB_FETCHMODE_ASSOC);
>
> foreach ($result as $k=>$v){
>
> $_SESSION[$k] = $v;
>
> }
>
> return true;
> } else {
> return false;
> }
> } // <<<
>
> what is to think about that?
Well, this surely is a solution that will work for your specific
situation, but IMHO it´s not something that will appeal to a large
number of users.
But the intention to provide a standard mechanism for retrieving
additional user data in the auth container has popped up a short while
ago, so you can use this solution now and use the new functionality in
your next project.
Btw.: I really wouldn´t make another database connection in that
function. Normally, at this stage of a script you will already have one
which you should re-use to make your script faster and less
resource-consuming.
Regards,
Markus
--
Markus Wolff <wolff@21st.de>