Sunday, 29 September 2013

CodeIgniter - Only allowed view your own profile, else 404

CodeIgniter - Only allowed view your own profile, else 404

I have a CodeIgniter controller function like this:
class User extends MY_Controller{
public function view($user_id)
{
if($user_id!==$this->get_session_user_id()){show_404();}
// ...
I only want each user to be allowed to view their own data, for example,
you can only view your own profile.
QUESTION: The code above seems to do the trick, but Im just wondering if
there is a better way?

No comments:

Post a Comment