let's say you have three fields id, field1, field2, username, password, etc. etc.
You have a login system and have multiple users. You want to use a field to use in your WHERE queries that select users rows according to their session id.
What is the best option and functions the fastest? I'm assuming referencing the id field would be faster than let's say a username field because it's an interger field rather than a string?
$uid = $PHPSESSID;
$query = SELECT * FROM users WHERE id = '$uid';
or just plain using a username session variable to select current session rows according to their username like:
$_SESSION['username'] = $_POST['username'];
$SQL= "SELECT * FROM users WHERE username='".($_POST['username'])."'
or should I do something different??? Is it safe to use the $PHPSESSID variable for session use? If I decide to select rows using the id is my first example the correct way of doing it? .....