You are interested in using "cookies" and "user authentication". Both of these are rich and complex topics. I suggest you use those as keywords to
Super Search here on PM, or on google, and also check out some of
merlyn's writings, such as
Basic Cookie Management
to help you get some background information and techniques.
There are quick answers to your questions, but getting a good grip on the big picture is priceless.
--bibo