Jump to content

What Is The Best Way To Uniquely Identify Members?


kensbeijing
 Share

Recommended Posts

From a purely aesthetic point of view, the auto-incremented index is easier to look at. If you ever need to manually trawl your tables and you use the member id as a foreign key in some tables, you'll find it easier spotting `1267` than the long string you just cited. It'll take longer to get complicated. Plus if that key is randomly generated, you'll need to check that no other user has it at the point of insertion, instead of leaving it up to the database to create that guaranteed-unique index for you.

Link to comment
Share on other sites

Also using the primary key from the users table is a great way to manage who owns what in another table.Example:Userid: 27 (primary key)Username: Jonathan

<?$id = 27;$result = mysql_query ("SELECT session FROM users WHERE id='$id' LIMIT 1") or die(mysql_error());// <-- Do the checks here?>

It's probably the fastest way of doing it since you don't have to search through a string (assuming the primary is INT-related)Another tip is to store user ids as cookies so user verification can go much smoother (rather than always searching by username, you can search by ID instead)Hope it helps!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...