私はソーシャルネットワークをコードイグナイターで再構築しており、ユーザーがログインしたときにログインした状態でセッションを開始する最適な方法を探しています (コードイグナイターセッションクラスを使用するのとは対照的ですか?彼らは自分のアカウントを作ります)
ユーザーを作成し、パスワードをハッシュおよびソルトし、ハッシュされたパスワードを使用してログインすることができました。
私のサイトには、ユーザーがサインインしているかどうかによって異なる「ログイン」ビューと「ログアウト」ビューがたくさんあります。
そうは言っても、ログイン時に、サインアップ時に作成された 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;
}
私は問題が何であるかを理解していません....