0

here, home.php is one controller file and i want to redirect into another controller file login.php but this code is not working. if you have any idea then plz help me...

home.php

<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Home extends CI_Controller{
    function __construct(){
        parent::__construct();
        $this->check_isvalidated();
    }

    public function index(){

        echo 'Congratulations, you are logged in.';

        echo "<br /><a href=''.base_url().'home/do_logout'>Logout</a>";
    }

    private function check_isvalidated(){
        if(! $this->session->userdata('validated')){
            redirect('login');
        }
    }

    public function do_logout(){
        $this->session->sess_destroy();
        redirect('login');
    }
}
?>
3
Contributors
2
Replies
25
Views
3 Years
Discussion Span
Last Post by Adrian_5
1

Hi,

is the URL helper automatically loaded? By enabling the log in CI you should be able to get more information about the error, just check into application/logs/. Try also to prefix the redirect link with a slash, for example:

redirect('/login');
0

Before redirecting, try $this->load->helper('url');. Also, try to do a redirect like so redirect('login','refresh');

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.