我最近继承了一个工作网站代码,它是用PHP在CodeIgnitor中设计的,我正在尝试进一步开发它。在尝试运行本地 (xampp)时,我遇到了一个问题:
代码构建得很好,并将我带到登录页面。在那里,我使用ion-auth登录,它成功地继续,保存了一个会话(这很有效),并继续登陆空间。然而,只要在登录后加载了任何页面,就会立即将用户注销并导航回登录页.。
与活动网站相比,代码中唯一改变的是它连接到的数据库、基本URL和一些导航。这里有什么问题?这是xampp、ion-auth或某些配置的问题吗?
// log the user in
public function login()
{
$this->data['title'] = $this->lang->line('login_heading');
// validate form input
$this->form_validation->set_rules('identity', str_replace(':', '', $this->lang->line('login_identity_label')), 'required');
$this->form_validation->set_rules('password', str_replace(':', '', $this->lang->line('login_password_label')), 'required');
if ($this->form_validation->run() == true)
{
// check to see if the user is logging in
// check for "remember me"
$remember = (bool) $this->input->post('remember');
if ($this->ion_auth->login($this->input->post('identity'), $this->input->post('password'), $remember))
{
// if the login is successful
// redirect them back to the home page
$this->session->set_flashdata('message', $this->ion_auth->messages());
redirect('/', 'refresh');
}
else
{
// if the login was un-successful
// redirect them back to the login page
$this->session->set_flashdata('message', $this->ion_auth->errors());
redirect('auth/login', 'refresh'); // use redirects instead of loading views for compatibility with MY_Controller libraries
}
}
else
{
// the user is not logging in so display the login page
// set the flash data error message if there is one
$this->data['message'] = (validation_errors()) ? validation_errors() : $this->session->flashdata('message');
$this->data['identity'] = array('name' => 'identity',
'id' => 'identity',
'type' => 'text',
'value' => $this->form_validation->set_value('identity'),
);
$this->data['password'] = array('name' => 'password',
'id' => 'password',
'type' => 'password',
);
$this->_render_page('auth/login', $this->data);
}
}正如马丁建议的那样,我试用了session_start();,它显示了以下内容:
A PHP Error was encountered
Severity: Warning
Message: ini_set(): A session is active.
You cannot change the session module's ini settings at this time
Filename: Session/Session.php
Line Number: 281
Backtrace:
File: C:\Programs\xampp\htdocs\modules\applications\azdemo\controllers\Shared.php
Line: 8
Function: __construct
File: C:\Programs\xampp\htdocs\modules\customers\azdemo\index.php
Line: 315
Function: require_once发布于 2020-12-26 12:48:53
嘿,我也遇到过同样的问题。它与php5.6和php7.2的离子支持有关。
他们对不同的php版本使用不同的散列技术。如果您已经升级了您的php版本,您可能需要检查ion-auth配置文件并更新散列方法。
以下是离子auth文档的一些内容:
您可以在bcrypt (来自PHP5.3)或argon2 (来自PHP7.2)之间进行选择。
指向文档的链接:离子-8月
让我知道它是否有帮助,如果你认为它有用的话就去投票吧!
发布于 2018-09-05 06:33:29
通过将php7.2.6降级为php5.5.38,临时解决了这个问题。可能有些库需要升级。我还从xampp切换到mamp pro 4,因为本地域问题,以及您不能轻松地将xampp的php版本降级。
希望这对将来的人有帮助。
https://stackoverflow.com/questions/52091083
复制相似问题