title: Passing uri segement to library in codeIgniter
body: <p>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..</p>
  
  <p>This is my controller,</p>
  
  <pre><code>&lt;?php
  class insertdata extends CI_Controller{
  
  function __construct(){
      parent::__construct();
  }
  
  //#############################################################################
  
  function updateprop(){
  
      $this-&gt;load-&gt;library('DataEntryForms_update');
  
              //get the uri segment
      $id = $this-&gt;uri-&gt;segment(3);
  
         //setting the session data
         $this-&gt;session-&gt;set_userdata('id',$id);
  
       $params [] = $this-&gt;uri-&gt;segment(3);
  
  
      $form_name = $this-&gt;input-&gt;post('function_name');
      switch ($function_name){
  
          case 1:
  
              $this-&gt;dataentryforms_update-&gt;function1();
  
              break;
          case 2:
              $this-&gt;dataentryforms_update-&gt;function2();
              break;
  
         }            
       }  
    }
  </code></pre>
  
  <p>This is my Library...</p>
  
  <pre><code>&lt;?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
  
   class DataEntryForms_update{
  protected  $CI;
  
   #######################################################
    //gets the CI instance    
    function __construct(){
  
  $this-&gt;CI =&amp; get_instance();
    }
  
  
   #############################################################
  
     function function1($params){
  
   $this-&gt;params = $params;
   print_r ($this-&gt;params);
  
   $project_id = $this-&gt;CI-&gt;session-&gt;userdata('id');
   echo $project_id;
   die();
      }   
  
  }
  </code></pre>
  
  <p>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</p>