title: Codeigniter URI routing and security
body: <p>In codeigniter or restful structure, the page can be route to through the URI </p>
  
  <p>For example, if I would like to look at the item list of id: 1 , then I just need to create a path like that:</p>
  
  <pre><code>domain.com/item/view/1
  </code></pre>
  
  <p>And in controller</p>
  
  <pre><code>function view() {
     $id = $this-&gt;uri-&gt;segment(3);
     //database get data and return view...
  } 
  </code></pre>
  
  <p>This should be the standard way to implement restful structure. However, when in the member system, and the item id is dependent to the user, how can I protect the link?</p>
  
  <p>So that other user can not brute force to try different ID and read the other member item. </p>
  
  <p>One approach is just compare the user_id and item_id in each function. But if the system is large that means I need to compare in each function and that is a lot of coding and checking . </p>
  
  <p>Are there any smarter way to reduce the overhead / coding ?</p>
  
  <p>Thanks </p>