Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
Thread: Get user info after logging in
01-17-2010, 04:43 AM #1
- Join Date
- Jun 2008
- Thanked 0 Times in 0 Posts
Get user info after logging in
What's the best way to get a user's info from a database after they login?
For example, if I want to welcome the user after logging in:
"Welcome back, [user's first name from database]."
Now, do i need to repeat my SQL statements each and every time, using something like:
SELECT username, first_name FROM users WHERE username = '$_SESSION['username']'
I'm confused, because during my tests I only have to access the columns I want without specifying the row I want on the page that the user is redirected to after logging in.
01-17-2010, 05:30 AM #2
- Join Date
- Dec 2004
- In a place far, far away...
- Thanked 1,043 Times in 1,019 Posts
Store their userid in a session. You can store other common data in a session like first name and last name when they first login however DO NOT store any personal information like passwords and phone numbers. Things you wouldn't really want public to just anyone. You can then use those sessions through out your site. You can also just store their userid in a session and query the database each time you want their information.