user id or username which is better to save in session and also in mysql which is the best way.
–> "select * from usertable where loginname=" . $_SESSION['username']; or
–> "select * from usertable where id=" . $_SESSION['id'];
whether integer comparison or string comparison which is the best comparison in SQL.
What you are thinking doesnt really make much sense to me, really!
Integer comparison or String comparison — Why do you think one will be faster that the other? Of course, if you go instruction by instruction Integer comparison will be faster, but why do you want that?
My answer: Stick to what ever you want. Choose the one that will be guaranteed to be unique. Plus, choosing username, isnt something great. Generate a unique ID for every user that is logged on. And store that ID into the
$_SESSION[..]. Obviously, you would need to have some mechanism to validate the ID, and associate it with the username.