I'm going to assume for the moment that people have to provide a username and password when they sign up. If not, they must be providing some unique identifier, such as email address.
Having said that, when they create a new account, you'll want to verify that the username is unique by looking at your database to determine if anyone already has it. If they do, you take them back to the first page with a message telling them that the username is not unique, try again. If it is unique, you insert a new record into your database with the new username and password (and first name, last name, email address, and whatever else you're collecting).
Immeidately thereafter, you search your database to get the user_id -- make sure every record in your database has an id -- for the person with that username.
Now that you know that, you can set a cookie (see the manual at php.net to learn how). It is best not to set the cookie with the actual ID. Rather, you should encrypt it or use some kind of multiplier on the user_id so that the cookie does not display the acutal user_id. (Someone could change their cookie to access someone else's records.)
With the cookie set, you can run a script at the top of every page looking for the cookie, and looking up the person's name based on the id in the cookie. If you're using a multiplier on the id #, you'll need to divide the cookie value by that same multiplier to get back to the user_id #.
I hope this helps.