我在这一份准备好的声明中过去一小时都在工作。
每次都会num_rows
返回$user_id
。
我已经在phpmyadmin中手动运行我的数据库查询,并且没有任何问题。 if ($statement = $mysqli->prepare("SELECT google_id FROM google_users WHERE google_id = ? LIMIT 1"))
{
$statement->bind_param("i", $user_id);
$statement->execute();
$statement->store_result();
if ($statement->num_rows < 1)
{
$alerts .= '<div class="alert alert-danger" role="alert">Your login session was not valid. Please log in again.</div>';
}
$statement->free_result();
$statement->close();
}
也设置得很好。
public function initSession()
{
$sessionConfig = new SessionConfig();
$sessionConfig->setOptions([
'cookie_lifetime' => 7200, //2hrs
'remember_me_seconds' => 7200, //2hrs This is also set in the login controller
'use_cookies' => true,
'cache_expire' => 180, //3hrs
'cookie_path' => "/",
'cookie_secure' => Functions::isSSL(),
'cookie_httponly' => true,
'name' => 'cookie name',
]);
$sessionManager = new SessionManager($sessionConfig);
// $memCached = new StorageFactory::factory(array(
// 'adapter' => array(
// 'name' =>'memcached',
// 'lifetime' => 7200,
// 'options' => array(
// 'servers' => array(
// array(
// '127.0.0.1',11211
// ),
// ),
// 'namespace' => 'MYMEMCACHEDNAMESPACE',
// 'liboptions' => array(
// 'COMPRESSION' => true,
// 'binary_protocol' => true,
// 'no_block' => true,
// 'connect_timeout' => 100
// )
// ),
// ),
// ));
// $saveHandler = new Cache($memCached);
// $sessionManager->setSaveHandler($saveHandler);
$sessionManager->start();
return Container::setDefaultManager($sessionManager);
}