Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I use "id" or "unique username"?

I am using PHP, AS3 and mysql.

I have a website. A flash(as3) website. The flash website store the members' information in mysql database through php. In "members" table, i have "id" as the primary key and "username" as a unique field.

Now my situation is: When flash want to display a member's profile. My questions:

  1. Should Flash pass the member "ID" or "username" to php to process the mysql query?

  2. Is there any different passing the "id" or "username"?

  3. Which one is more secure?

  4. Which one you recommend?

I would like to optimize my website in terms of security and performance.

like image 356
roa3 Avatar asked Nov 30 '22 12:11

roa3


1 Answers

1) Neither is inarguably the thing it should do.

2) The ID is probably shorter and minisculely faster to look up. The ID gives away slightly more information about your system; if you know that a site uses serial IDs at all, and you know what one of them is, that's pretty much as good as knowing all of them, whereas knowing one username does not tell you the usernames of any other users. On the other hand, the username is more revelatory of the user's psychology and may constitute a password hint.

3) Both have extremely marginal downfalls, as described in item 2.

4) I'd use the ID.

like image 93
chaos Avatar answered Dec 04 '22 07:12

chaos