php - Codeigniter URI routing and security -
in codeigniter or restful structure, page can route through uri
for example, if @ item list of id: 1 , need create path that:
domain.com/item/view/1
and in controller
function view() { $id = $this->uri->segment(3); //database data , return view... }
this should standard way implement restful structure. however, when in member system, , item id dependent user, how can protect link?
so other user can not brute force try different id , read other member item.
one approach compare user_id , item_id in each function. if system large means need compare in each function , lot of coding , checking .
are there smarter way reduce overhead / coding ?
thanks
in domain.com/item/view/1
, stands base_url/controller/method
so if create controller (item
), function (view
).
class item extends ci_controller { public function __construct() { parent::__construct(); } public function view($id) { //so in $id assign 3rd value it. $new_id = $id; echo $new_id; }
Comments
Post a Comment