Welcome Guest, Not a member yet? Register   Sign In
Creating a new lib
#5

[eluser]John_Betong_002[/eluser]
I have just tried and tested this in an application and it works fine:


Code:
// FILE:  ./your_application/controllers/your_controller.php
function index()
{
  error_reporting(-1);
  ini_set('display_errors',1);

  $this->load->library('Authentication');
  die;




// FILE:  ./your_application/libraries/Authentication.php
<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Authentication {
    
// var $CI;

function __construct()
{
  
  $this->CI =& get_instance();
      
  $this->CI->load->library('session');
  $is_logged_in = $this->CI->session->userdata('is_logged_in');
  if(!isset($is_logged_in) || $is_logged_in != true)
  {
    echo 'You don\'t have permission to access this page. <a href="../login">Login</a>';    
    die();        
  }
}
}



// Output: You don't have permission to access this page. Login
&nbsp;
&nbsp;


Messages In This Thread
Creating a new lib - by El Forum - 06-15-2011, 08:33 PM
Creating a new lib - by El Forum - 06-16-2011, 04:15 AM
Creating a new lib - by El Forum - 06-16-2011, 05:33 AM
Creating a new lib - by El Forum - 06-16-2011, 02:47 PM
Creating a new lib - by El Forum - 06-16-2011, 06:42 PM
Creating a new lib - by El Forum - 06-16-2011, 07:39 PM
Creating a new lib - by El Forum - 06-16-2011, 07:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB