i'm building a web application in node.js, and using mysql as a database, now, if i implement a login, how do i know what information to show in my pages, and of course how do i keep track of the user to show them different pages that retrieves data from the database, because all the queries i'm doing needs to take in consideration the user ID, which i guess i can get it in the login page since the username is unique, what is this called? i heared of sessions but don't know what they are and if they are what i need. and if i make a variable to store this id, where do i call it? in the app.js file? thanks
Asked
Active
Viewed 913 times
0
-
Usually websites use session to keep track if a user has logged in instead of database. Imagine facebook storing user's activity in database, how big would that be, there's modules helping you manage sessions in node.js. – hkisthebest Dec 13 '19 at 01:39
1 Answers
0
You can keep trace of the last id insert by calling an anonymous function in callback taking error and result as parameters. The last insert id will be in the InsertId property of your result.
See Retrieve last inserted id with Mysql
Hope it helps :)

Narek
- 20
- 6