Step 1). Download and extract all the files from archives of both grocery crud and tank auth in Codeigniter.
Step 2) Import their schema and install them according to the instruction given on their respective sites and test whether they are working individually.
Step 3) Change address of your default route controller at routes.php to
$route['default_controller'] = "examples"; // grocery crud controller
Step 4) In examples controller construct paste following line
$this->load->database();
$this->load->helper('url');
$this->load->library('tank_auth'); // we need to load tank auth library in example controller
$this->load->library('grocery_CRUD');
Step 5) In index function of examples controller, write code to check whether user is logged in or not:
public function index()
{
if (!$this->tank_auth->is_logged_in()) {
redirect('/auth/login/');
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array(),'data' => $data));
}
}
Step 6) Now in example views create a log out link:
Hi, ! You are logged in now.
Step 2) Import their schema and install them according to the instruction given on their respective sites and test whether they are working individually.
Step 3) Change address of your default route controller at routes.php to
$route['default_controller'] = "examples"; // grocery crud controller
Step 4) In examples controller construct paste following line
$this->load->database();
$this->load->helper('url');
$this->load->library('tank_auth'); // we need to load tank auth library in example controller
$this->load->library('grocery_CRUD');
Step 5) In index function of examples controller, write code to check whether user is logged in or not:
public function index()
{
if (!$this->tank_auth->is_logged_in()) {
redirect('/auth/login/');
} else {
$data['user_id'] = $this->tank_auth->get_user_id();
$data['username'] = $this->tank_auth->get_username();
$this->_example_output((object)array('output' => '' , 'js_files' => array() , 'css_files' => array(),'data' => $data));
}
}
Step 6) Now in example views create a log out link:
Hi, ! You are logged in now.
No comments:
Post a Comment