Need help with a login system

Discussion in 'PHP' started by MCJim, Aug 23, 2008.

  1. #1
    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! :)
     
    MCJim, Aug 23, 2008 IP
  2. JLEville

    JLEville Peon

    Messages:
    147
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    JLEville, Aug 23, 2008 IP
  3. ForumJoiner

    ForumJoiner Active Member

    Messages:
    762
    Likes Received:
    32
    Best Answers:
    0
    Trophy Points:
    83
    #3
    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).
     
    ForumJoiner, Aug 23, 2008 IP
  4. Barti1987

    Barti1987 Well-Known Member

    Messages:
    2,703
    Likes Received:
    115
    Best Answers:
    0
    Trophy Points:
    185
    #4
    Barti1987, Aug 23, 2008 IP