• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prevent access to pages if session is not set

#1
Is there a way that redirects user to login page if he tries to access a page without logging in.

I have my attempt on doing this but to no avail I failed 

Code:
class Navigation extends CI_Controller
{
protected $data;
public function __construct()
{
parent::__construct();
$this->load->model('user_model'); 
$this->load->helper('url');
if (!$this->session->userdata('userID') === TRUE){
header('Location: index.php');
}
}

/*
*Load the index page
*/
public function index()
{
$this->load->view('index');
}
    

    public function edit(){
        $this->page('dashboard/change_pass','dashboard/change_pass');
    }
/*
*Load the admin dashboard page
*/
public function dashboard()
{
$this->page('dashboard/index');
Reply


Messages In This Thread
Prevent access to pages if session is not set - by nullstrike - 08-04-2017, 06:32 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.