By storing information about the user id or user session as a cookie in the end-user's web browser.
Keep in mind, if you just want to simply store user id as a cookie without messing with PHP sessions, encrypt it so that it can't just be changed to a different id by the end-user.