LiveUser problems with staying logged in
| From: | Michael Worobcuk | Date: | Wed, 17 Jan 2007 11:37:35 +0000 |
| Subject: | LiveUser problems with staying logged in | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-26356@lists.php.net to get a copy of this message | ||
Hi,
I am not sure, if this is the right place to ask this question, my apologize if I am wrong...
I am having problems staying logged in with LiveUser.
The User can log in, but when clicking on link that points to another site of my page, LiveUser dows not know the user anymore.
The Cookie is created, but with e.g. $LU ->getProperty('handle') LiveUser returns 0.
I trie to set $remember to true and that works. But in my opinion, that solution is not very secure, since the next user on the computer would have access to the whole database, if I would forget to logout.
Here is my config file, maybe someone can tell what is wrong:
<?php
require_once 'LiveUser/Admin.php';
require_once 'LiveUser.php';
require_once "MDB2.php"; //MDB2::PEAR
$home_path="/support_data";
//set this to fit for the login part
ini_set("include_path", '../../libs/PEAR/' . PATH_SEPARATOR . ini_get("include_path"));
$GLOBALS['_LIVEUSER_DEBUG'] = true;
$db_user = '*******';
$db_pass = '*******';
$db_host = 'localhost';
$db_name = '******';
$dsn = "mysql://$db_user:$db_pass@$db_host/$db_name";
$backends = array(
'MDB2' => array(
'options' => array(
'debug' => true,
'debug_handler' => 'echoQuery',
)
)
);
if (!array_key_exists('storage', $_GET))
{
$storage = 'MDB2';
}
elseif (isset($backends[$_GET['storage']]))
{
$storage = strtoupper($_GET['storage']);
}
else
{
exit('storage Backend not found.');
}
require_once $storage.'.php';
function echoQuery(&$db, $scope, $message)
{
//Var_Dump::display($scope.': '.$message);
}
$dummy = new $storage;
$db = $dummy->connect($dsn, $backends[$storage]['options']);
if (PEAR::isError($db))
{
echo $db->getMessage() . ' ' . $db->getUserInfo();
die();
}
$db->setFetchMode(constant($storage.'_FETCHMODE_ASSOC'));
$conf =
array(
'debug' => true,
'session' => array(
'name' => 'Support Database','varname' => 'ludata' ), 'login' => array(
'force' => true,'regenid' => true ), 'logout' => array( 'destroy' => true, ), 'cookie' => array(
'name' => 'loginInfo', // name of the Remember me cookie
'lifetime' => 30, // cookie lifetime in days
'path' => null, // cookie path ?
'domain' => null, // cookie domain ?
'secret' => 'test', // the encryption key for the RC4 algorithm
'savedir' => '.', // absolute path to writeable directory ?
// (no trailing slash)
'secure' => false, // whether cookie only send over secure connection
),
'authContainers' => array(
'DB_Local' => array(
'type' => $storage,
'expireTime' => 3600, 'idleTime' => 1800,'storage' => array( 'dbc' => $db, 'dsn' => $dsn, 'prefix' => 'liveuser_', 'tables' => array( 'users' => array( 'fields' => array( 'name' => false, 'email' => false, 'isactive' => false, ), ), ), 'fields' => array( 'name' => 'text', 'email' => 'text', 'isactive' =>'text', ), 'alias' => array( 'name' => 'name', 'email' => 'email', 'auth_user_id' => 'user_id', 'isactive' => 'isactive', ), // 'force_seq' => false ), ) ), 'permContainer' => array( 'type' => 'Complex', 'alias' => array(), 'storage' => array( $storage => array( 'dbc' => $db, 'dsn' => $dsn, 'prefix' => 'liveuser_', 'tables' => array('liveuser_perm_users'), 'fields' => array('perm_type'), 'alias' => array('perm_type' => 'perm_type'), // 'force_seq' => false ), ), ), ); $LUA =& LiveUser_Admin::factory($conf); $logconf = array('mode' => 0666, 'timeFormat' => '%X %x'); $logger = &Log::factory('file', 'liveuser_test.log', 'ident', $logconf); $LUA->log->addChild($logger); $LUA->init(); $LU = &LiveUser::singleton($conf); if (! $LU->init()) { //var_dump( $LU->getErrors()); die('init Error /Line 123'); } $handle = (array_key_exists('handle', $_REQUEST)) ? $_REQUEST['handle'] : null; $passwd = (array_key_exists('passwd', $_REQUEST)) ? $_REQUEST['passwd'] : null; $logout = (array_key_exists('logout', $_REQUEST)) ? $_REQUEST['logout'] : false; if ($logout) {
$LU->logout(true); // deletes the RememberMe cookie} elseif(! $LU->isLoggedIn() || ($handle && $LU->getProperty('handle') != $handle)) { if (!$handle) { $LU->login('0', '0', true); } else { $LU->login($handle, $passwd, $remember = false); } } ?> Thank you very much for your help