Hi Kien,
Usually when a user is logged in he will get another role than the anonymous user (not logged in). In the Navigation section you can choose to have a different home page or home microflow per role.
Using SQL DB is not a safe way to check whether a user is logged in. The login action is done at the client and the DB at the server site. So if you want a user to automatically login based on earlier actions, you should use a secure HTTP cookie with a token in it. Otherwise there is no way that you can link the client session to an earlier login of the user.
Best regards,
Diederik Wentink