LiveUser init() x2 fails
| From: | Michael | Date: | Tue, 20 Jul 2004 03:11:09 +0000 |
| Subject: | LiveUser init() x2 fails | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13756@lists.php.net to get a copy of this message | ||
Hi,
Perhaps I am going about this wrong, but when calling init() 2 times, the second time around init returns a PEAR_Error. What I am trying to do is first re-initialize a session, but if there is no session to restore, I want to login an anonymous user. I got something like this going on:
$fw_user =& LiveUser::factory($fw_user_config);
if (PEAR::isError($fw_user)) {
trigger_error($fw_user->getMessage(), E_USER_ERROR);} $user = $fw_user->init(); if (PEAR::isError($user)) {
trigger_error($user->getMessage() . ' ' .$user->getUserInfo(), E_USER_WARNING);} if ($user === false) {
// authenticate as anonymous
$user = $fw_user->init('anonymous');
if (PEAR::isError($user)) {
Var_Dump::display($user); die();
trigger_error($user->getMessage() . ' ' .$user->getUserInfo(), E_USER_WARNING);
}
}
The gotcha is the second time init is called with 'anonymous' as the username, it returns a PEAR_Error LIVEUSER_ERROR_NOT_SUPPORTED saying that it cannot locate the auth container 'M.php' (which should be MDB2.php). I don't understand why on the second call (the first call does not raise an error), init() garbles the config array I defined when instantiating LiveUser as a singleton.
But, besides this, should I be approaching this problem another way?
Thanks,
Michael