I'm working on a CodeIgniter project.. I want to pass a uri segment from a controller to my own library. I could not able to do it.. I tried it using session , but it won't work.please help me..
This is my controller,
<?php
class insertdata extends CI_Controller{
function __construct(){
parent::__construct();
}
//#############################################################################
function updateprop(){
$this->load->library('DataEntryForms_update');
//get the uri segment
$id = $this->uri->segment(3);
//setting the session data
$this->session->set_userdata('id',$id);
$params [] = $this->uri->segment(3);
$form_name = $this->input->post('function_name');
switch ($function_name){
case 1:
$this->dataentryforms_update->function1();
break;
case 2:
$this->dataentryforms_update->function2();
break;
}
}
}
This is my Library...
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class DataEntryForms_update{
protected $CI;
#######################################################
//gets the CI instance
function __construct(){
$this->CI =& get_instance();
}
#############################################################
function function1($params){
$this->params = $params;
print_r ($this->params);
$project_id = $this->CI->session->userdata('id');
echo $project_id;
die();
}
}
In Library I tried to get the session data,but I'm get the session data 'id' as 0 ... When I used uri->segemnt(2) . it will get the correct value, but uri->segment(3) did not work ...please help me