views:

187

answers:

2

Busy building my first web application in CodeIgniter and wanted to work out the best way of gathering ID in my Admin function for Edit, Delete statements.

I realised I can use any of the following:

  1. Pass the ID through the controller.
  2. Collect the ID from the URI segment.
  3. Collect the ID from a hidden form field.

Which is the best based on security concerns. i.e. People fiddling with the URL, etc.

+1  A: 

If this is for an admin section, it should may no difference. Unless a user is authorized to view the output of say, the Admin Controller, they should see "page does not exist" for each one of those methods.

Jonathan Sampson
Public-facing Admin Pages? Those shouldn't exist :)
Jonathan Sampson
+1  A: 

I prefer to use the URL for unique IDs, that way you get nice-looking URLs that people can bookmark. You shouldn't rely on how you pass the data for security, you should be doing input validation within your controller regardless of how you pass it.

Parrots
Well specifically for IDs first I cast them back to an int to make sure no string data is trying to be passed in. Then I'll do whatever business logic and DB querying I need to do to make sure they have access to that specific record. Could be something as simple as "are they an admin, ok then they have access" to "get the record, was it created by them?".
Parrots