I've never done a login system before so I'm not sure how they work. I have a database with user names and passwords. How can I allow users to 'login'? Would I just create a cookie given that they enter a user name and the correct password? This seems right to me, but please let me know. Thanks in advance!
When they login, check login information with database and if they match, create a cookie....check that cookie is set on every page that only users are allowed to visit...delete the cookie when they logout. PM me if you want me to custom make a login/logout script for you.
There are 3 cases: 1. The user buys a product, login, then download and leaves. In this case, there is no reason for cookies. 2. If you want to allow the user to visit several pages, without asking for login details on each page, you can use cookies or sessions. The problem with cookies is that some people have them disabled. In this case, the alternative is to use sessions. This happens because http protocol "forgets" that the user is logged, when a user visit another page. If you go to: http://www.ineasysteps.com/books/details/?184078282x (don't worry, it's not an affiliate link ) they offer you the examples from the book called "PHP 5 in easy steps". You can download the examples even if you don't have the book. Inside the archive, you'll find a file called "authenticate.html" (is a very simple example). It works with the file called "authenticate.php", from the same folder. The link for the archive is at the bottom at the page from InEasySteps.com, and it's called "An archive containing all the example files used in "PHP 5 in easy steps" (I'm not sure if I'm allowed to post the direct link to the archive).