0

So right now I'm identifying the user via their email [given that they allow it during the Facebook log in process]. But I feel people are able to change their main email address associated with their account, and if they do, it might mess up my app.

So is it better to use their Facebook id instead of email? I believe id is permanent and unique to an individual's Facebook account, correct?

$user['email'] or $user['id']?

Jeromie Devera
  • 376
  • 2
  • 6
  • 21
  • 1
    Yes the id is permanent and unique. Email people can change and some people may not have it – WizKid May 30 '14 at 04:51

1 Answers1

3

Yes, the correct way to identify users (And use as Primary Key in your databases) is with the Facebook Id.

Email people can change and there is people that don't have an email on Facebook.

Another advantage of using the ID, is that you don't need the users to give you access to their email (it's a different permission). Some people might not want to do that!

Gaston Claret
  • 1,000
  • 1
  • 7
  • 27
  • How long is the string of the user's id? Can;t seem to find it specified in the docs. – Jeromie Devera May 30 '14 at 04:52
  • 1
    They are 64-bits ints for now. – WizKid May 30 '14 at 04:53
  • Hmm, facebook identifies `id` as a string datatype. What would a 64bit int convert to when put as strings [might be an obvious question, but i'd like to get it correct so as to minimize any delay when developing.] I'm thinking 16 characters, since md5 is a 128bit hashing algorithm and its output is 32 characters long. I'm storing these in a mysql database. – Jeromie Devera May 30 '14 at 04:56
  • 1
    You can read about it more here http://stackoverflow.com/questions/7566672/whats-the-max-length-of-a-facebook-uid.. But it you don´t want too, I would also suggest you make it a bit longer than it needs to be, in case of future changes in the API (They change things around often) – Gaston Claret May 30 '14 at 04:59
  • Thanks, I ended up using varchar(128) as said in the link above. [OP, I will pick your answer as the correct one in a bit. SOF isn't letting me right now.] – Jeromie Devera May 30 '14 at 05:02
  • @Jeromie Devera: `128bit varchar` <--- what's this? o_O – zerkms May 30 '14 at 05:06