Re: extending Auth DB container

From: Date: Thu, 21 Mar 2002 03:05:09 +0000
Subject: Re: extending Auth DB container
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-1008@lists.php.net to get a copy of this message
Ok, done some testing and found that it could be a variable scoping problem. It works if I change setAuth to something like: function setAuth($username, $data = null) { global $auth; $session = &Auth::_importGlobalVariable("session"); if (!isset($session['auth'])) { session_register("auth"); } // $session['auth'] = array( $auth = array( 'registered' => true, 'username' => $username, 'timestamp' => time(), 'idle' => time() ); if (!empty($data)) { // $session['auth']['data'] = $data; $auth['data'] = $data; } } -- Thanks! It works great. But now I have another problem. The session does not seem to register. After I login, the session file only contains !auth| When I go back to the page, I'm reported as not login. Anything I missed here? On 20 Mar 2002, at 19:10, Martin Jansen wrote: > On Thu, 21 Mar 2002 01:50:45 +0800, Ken Chew wrote: > > >I am a new user of pear and wanted to extend the DB container > >class for Auth to add some of my own function for the user auth. > > > >But I note that this part > > 269 function _factory($driver, $options = "") > > 270 { > > 271 $storage_path = "Auth/Container/" . $driver . ".php"; > > 272 $storage_class = "Auth_Container_" . $driver; > > 273 > > 274 require_once $storage_path; > > 275 > > 276 return new $storage_class($options); > > 277 } > > > >default to looking for the driver in the pear directory. > > > >Now, I do not have write access to this directory (actually do not > >want to write to there). If I want to put my own driver file > >somewhere, what should? > > For now you can do: > > class MyAuth extends Auth { > > function MyAuth($filename, $name, $options = "") > { > /* .... */ > > $this->storage = $this->_factory($filename, $name, $options); > } > > function _factory($filename, $name, $options) > { > require_once $filename; > $storage_class = "Auth_Container_" . $name; > > return new $storage_class($options); > } > } > > and then call it via > > $foo = new MyAuth("/foo/bar/file.php", "myContainer"); > > Perhaps such a feature will be natively supported by Auth > one fine day, but not today and not tomorrow :-). > > - Martin > > -- > Martin Jansen, <mail@martin-jansen.de> > http://www.martin-jansen.de/ > >

« previous php.pear.general (#1008) next »