[英]How to redirect user to a different controller on refreshing the page
I am working on codeigniter. 我正在开发codeigniter。 I am implementing signin functionality and when user signs in i call this controller
我正在实现登录功能,当用户登录时我会调用此控制器
function validate_credentials()
{
$this->load->model('membership_model');
$query = $this->membership_model->validate();
if($query==1)
{
$data = array
(
'username'=>$this->input->post('username'),
'is_logged_in' => true
);
$email=$data['username'];
$this->session->set_userdata('email_of_user',$email);
$this->load->model('search_peoplee');
$data['userid']= $this->search_peoplee->get_userid_from_email($email);
foreach ($data['userid'] as $row)
{
$one=$row->userid;
}
$data['result']=$this->membership_model->friend_notify($one);
$data['count']=$this->search_peoplee->get_friends_count($one);
$this->load->model('search_peoplee');
$data['values']= $this->search_peoplee->get_notifications($one);
$data['count_notify']=$this->search_peoplee->get_notifications_count($one);
$this->session->set_userdata('lookatit','no');
$this->load->view('home_screen',$data);
}
elseif($query==2)
{
$data['main_content']='email_not_found';
$this->load->view('includes/template',$data);
}
else
{
$this->error_index();
}
}
this validates the credentials and stores a session, this controller calls a model "$this->membership_model->validate();" 这将验证凭据并存储会话,此控制器将调用模型“ $ this-> membership_model-> validate();”。 which picks the value form view and check that if user exists, the problem is when i retype the address it takes me to the login page and says sign in again as the model reads empty values.
它选择值表单视图并检查用户是否存在,问题是当我重新输入地址时,它会将我带到登录页面,并在模型读取空值时说再次登录。 How to avoid this.
如何避免这种情况。 help!!!
救命!!!
after you have authenticated, how about setting a session variable. 身份验证后,如何设置会话变量。 so,
所以,
$this->session->set_userdata('authenticated',TRUE);
then in the controller, first check if the user is authenticated and do a redirect, otherwise go to the validate_credentials method ?? 然后在控制器中,首先检查用户是否已通过身份验证并进行重定向,否则转到validate_credentials方法?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.