我一直在代码点火器中重建我的社交网络,并正在寻找一种最佳方式来启动用户登录时登录的会话(可能与使用代码点火器会话类相反?因为我想使用他们在何时创建的 ID他们记账)
我已经能够创建一个用户并对他们的密码进行哈希和加盐,并使用哈希密码登录他们。
我的网站将有很多“登录”和“注销”视图,这些视图因用户是否登录而异。
话虽如此,登录后我想使用注册时创建的 id 启动登录会话。
这是我的控制器,它将用户登录减去我正在尝试做的事情。
function validate_credentials()
{
$this->load->model('user_model', 'um');
$login = $this->input->post('submit');
$this->load->library('encrypt');
if($login) {
$user = $this->um->
validate(array('email' => $this->input->post('email')));
if( $user ) {
if($user->password == $this->encrypt->sha1( $user->salt .
$this->encrypt->sha1($this->input->post('password')))) {
$this->session->set_userdata( array('email' =>
$this->input->post('email')
));
redirect('account/dashboard');
exit;
}
}
}
$this->index();
}
/*---------- EDIT ----------*/
Getting these errors:
Message: Cannot modify header information - headers already sent by (output started at /Users/mycomputer/Sites/cl_ci_new/application/controllers/auth.php:44)
Filename: libraries/Session.php
Line Number: 672
Message: Cannot modify header information - headers already sent by (output started at /Users/mycomputer/Sites/cl_ci_new/application/controllers/auth.php:44)
Filename: helpers/url_helper.php
Line Number: 542
and here are those lines in my code or the Session.php file:
// Set the cookie
setcookie(
this->sess_cookie_name,
$cookie_data,
$expire,
$this->cookie_path,
$this->cookie_domain,
$this->cookie_secure
);
和 url_helpers.php:
switch($method)
{
case 'refresh' : header("Refresh:0;url=".$uri);
break;
default : header("Location: ".$uri, TRUE, $http_response_code);
break;
}
我不明白问题是什么......