I will go ahead and move your post to "General Web Building".
To give a quick answer to your question, such things as logins and profiles are handled on the back end of a website-- the server side. That's where you get into languages such as PHP, ASP, ColdFusion, etc. On this back end is where you can interact with files on the server, or more typically, a database such as MySQL. Using a database, you can store a person's account information (username, password, etc) in tables and control access to certain pages using sessions. In PHP sessions works by creating a cookie on the client PC that contains encrypted information, and your PHP scripts check this cookie on every request.
There are boxed solutions for this sort of thing-- the well-known CMS products (Drupal, Wordpress, Joomla, etc) usually come with account management, or have plugins to handle it. But it's a pretty basic functionality and many web developers have rolled their own solutions.