简体   繁体   English

如何在刷新页面时将用户重定向到其他控制器

[英]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.

相关问题 当用户刷新页面或回来时如何将用户重定向到另一个页面 - How to redirect the user to another page when he is refreshing the page or coming back 如何在Laravel 5.2中从同一控制器功能重定向不同页面 - How to redirect different page from same controller function in laravel 5.2 如何在laravel 5.2默认注册控制器中将用户重定向到特定页面 - How to redirect user to specific page in laravel 5.2 default register controller 如何将magento管理页面重定向到不同的控制器操作? - How to redirect magento admin page to different controller action? 如何基于多用户系统防护将用户重定向到其他页面? - How to redirect user to different page based on the guard for multi user system? 如果用户是第一次登录,如何将用户重定向到某个不同的页面 - How to redirect the user to some different page if user is logging for the first time 标头重定向不刷新重定向页面 - Header redirect not refreshing redirect page 如何根据 WordPress 中的表单条目数将用户重定向到不同的页面 - How to redirect a user to a different page based on the number of form entries in WordPress 如何在php和mysql中按用户类型重定向到不同的页面 - How to redirect into different page by user type in php and mysql 我如何将我的用户和管理员重定向到其他页面 - How can i redirect my user and admin to different page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM