r/DatabaseHelp • • Aug 12 '15
Accessing database using information already in the database.
This is a general question. You don't have to answer in depth if you don't like. I wouldn't mind just something to google. My google searches have been fruitless because I don't know what this is called.
Poorly phrased question: How do you access database information using information from the database?
Example that will (hopefully) clear up my terrible question:
I have a website that has two users.
When user A logs in, it displays "Welcome [user A's name].
When user B logs in, it displays "Welcome [user B's name].
How does it "know" that user A is logged in and not user B? It seems reasonable that I'd use a script that did something like "get [name] from table where [userID] is the currently logged in user".
How does it know who the currently logged in user is?
Sorry... I know this is kind of a shit show of an explanation, but I legitimately don't know the words to clear it up.
View all comments
Show parent comment
2
u/marcus13345 Aug 16 '15
sessions are used to describe authentication across multiple web pages, yes. but something simple to start out with may be just expirimenting with having a cookie populated by javascript that holds the current user, so that outgoing requests (say to php) will know what to look for in a table. so if user = "marcus" in your cookies, php will do a select username from tbl_users where username = $cookies['name'];