storing login data and retrieving it after login on multiple sites

on the first subpage there is a login form, after logging in it takes the user to the page with his data etc. how to store the data of which user is logged in to correctly retrieve the data from the database?