Codeigniter: Redirect not working

alex

I've searched through some of the other posts on here with this similar issue, but I haven't managed to make this work. don't know what the problem is.

  • I'm trying to redirect to the main Home controller after logon/logout from the Login controller

I have the error_reporting(E_ALL) set in my development environment variables and there's no error and tried loading the url helper in my Login controller: $this->load->helper('url');

Here is the main Home controller:

public function index() {
        if (($this->session->userdata('username') != "")) {
            $this->user();
        } else {
            $this->load->view('login');
        }
    }

Here's the Login controller:

public function index()
    {
        $this->load->view('login');
    }
    public function logout()
    {
                $profile = array(
                    'userid' => '',
                    'username' => '',
                    'role' => '',
                    'custid' => '',
                    'custname' => '',
                    'logged_in' => FALSE 
                    );

        $this->session->unset_userdata($profile);
        $this->session->sess_destroy();
        redirect('/', 'refresh');
    }
    public function logon()
    {
        $data = $_POST;
        $this->db->select("people.*, customers.name as 'custname', customers.id as 'custid'");
        $this->db->from('people');
        $this->db->join('customers', 'customers.id = people.customer');
        $this->db->where('people.username', $data['username']);
        $this->db->where('people.password', $data['password']);
        $query = $this->db->get();
        $results = $query->result_array();

        if(count($results) > 0)
        {
            $profile = array(
               'username'  => $results[0]['username'],
               'userid'  => $results[0]['id'],
               'role'  => $results[0]['role'],
               'date_format'  => $results[0]['date_format'],
               'custname' => $results[0]['custname'],
               'custid' => $results[0]['custid'],
               'logged_in' => TRUE
            );

            $this->db->select("*");
            $this->db->from('hub.settings');
            $this->db->where('customer', $profile['custid']);
            $query = $this->db->get();
            $results = $query->result_array();
            if(count($results) > 0)
            {
                $profile['contacthtml'] = $results[0]['contacthtml'];
                $profile['accentcolor'] = $results[0]['accentcolor'];
            }

            $this->session->set_userdata($profile);
            redirect('/', 'refresh');
        }else{
            redirect('/login', 'refresh');
        }
    }

내가 얻는 것은 URL http://localhost:85/login/logon과 빈 화면뿐입니다.

나는 또한 시도했다 : redirect('/home', 'refresh');, redirect('/home');, redirect('home', 'refresh');, redirect('home/', 'refresh');,redirect('/home/', 'refresh');

편집하다:

이것은 개발 도구의 네트워크 섹션의 응답입니다.

여기에 이미지 설명 입력

AdrienXL

주석에서 언급했듯이 구성 파일의 base_url은 후행 슬래시로 설정해야합니다. 귀하의 경우 :

$config['base_url'] = 'http://localhost:85/';

이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.

침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제

에서 수정
0

몇 마디 만하겠습니다

0리뷰
로그인참여 후 검토

관련 기사

분류에서Dev

Behaviour of redirect in codeigniter

분류에서Dev

CodeIgniter: redirect from embed view

분류에서Dev

Codeigniter redirect () 및 헤더

분류에서Dev

URL redirect not working with .htaccess not working

분류에서Dev

Django redirect() not working

분류에서Dev

jquery redirect on keydown is not working

분류에서Dev

Form action not working in codeigniter

분류에서Dev

Codeigniter - Pagination not working correctly

분류에서Dev

Codeigniter / Migration Not Working

분류에서Dev

Codeigniter version 2.0.2 redirect loop issue

분류에서Dev

Primefaces comondButton redirect stopped working

분류에서Dev

CodeIgniter Flexi Auth Demo is Not working

분류에서Dev

Codeigniter not working properly when hosted

분류에서Dev

Redirect 301 on changed root name not working

분류에서Dev

wp_logout_url($redirect); is not working

분류에서Dev

Redirect not working as I'm expecting in Rails

분류에서Dev

Codeigniter image resize library not working properly

분류에서Dev

Codeigniter send mail working in localhost but not in server

분류에서Dev

In Laravel " return Redirect::back()->withErrors($Validator)->withInput(); " Not Working For me?

분류에서Dev

ZF2 redirect() not working while header location does

분류에서Dev

Redirect from the domain with www to the root domain - working but not completely properly

분류에서Dev

Redirect to action based on role not working. Maybe routing needed?

분류에서Dev

Codeigniter and mod_rewrite, rewrite not working and 404 error

분류에서Dev

Codeigniter Router $this->uri->segment not working exactly

분류에서Dev

jquery ajax form validation not working with GET method codeigniter

분류에서Dev

GroceryCRUD add, edit buttons not working when enabling CodeIgniter CSRF protection

분류에서Dev

Codeigniter Flash data is not working 1 out of 10 time

분류에서Dev

Codeigniter PHP의 redirect ()에서 SESSION 변수가 재설정 됨

분류에서Dev

моя проверка формы не работает должным образом для поля выбора в codeigniter

Related 관련 기사

  1. 1

    Behaviour of redirect in codeigniter

  2. 2

    CodeIgniter: redirect from embed view

  3. 3

    Codeigniter redirect () 및 헤더

  4. 4

    URL redirect not working with .htaccess not working

  5. 5

    Django redirect() not working

  6. 6

    jquery redirect on keydown is not working

  7. 7

    Form action not working in codeigniter

  8. 8

    Codeigniter - Pagination not working correctly

  9. 9

    Codeigniter / Migration Not Working

  10. 10

    Codeigniter version 2.0.2 redirect loop issue

  11. 11

    Primefaces comondButton redirect stopped working

  12. 12

    CodeIgniter Flexi Auth Demo is Not working

  13. 13

    Codeigniter not working properly when hosted

  14. 14

    Redirect 301 on changed root name not working

  15. 15

    wp_logout_url($redirect); is not working

  16. 16

    Redirect not working as I'm expecting in Rails

  17. 17

    Codeigniter image resize library not working properly

  18. 18

    Codeigniter send mail working in localhost but not in server

  19. 19

    In Laravel " return Redirect::back()->withErrors($Validator)->withInput(); " Not Working For me?

  20. 20

    ZF2 redirect() not working while header location does

  21. 21

    Redirect from the domain with www to the root domain - working but not completely properly

  22. 22

    Redirect to action based on role not working. Maybe routing needed?

  23. 23

    Codeigniter and mod_rewrite, rewrite not working and 404 error

  24. 24

    Codeigniter Router $this->uri->segment not working exactly

  25. 25

    jquery ajax form validation not working with GET method codeigniter

  26. 26

    GroceryCRUD add, edit buttons not working when enabling CodeIgniter CSRF protection

  27. 27

    Codeigniter Flash data is not working 1 out of 10 time

  28. 28

    Codeigniter PHP의 redirect ()에서 SESSION 변수가 재설정 됨

  29. 29

    моя проверка формы не работает должным образом для поля выбора в codeigniter

뜨겁다태그

보관