SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Logging in via cookies

    Hello,
    I'm just about ready to write a script so that registered users on a new website I'm building can login and have access to a members area. I decided that I'll keep them logged in with PHP sessions, but I want them to be able to check a box when they log in so that their username and password is stored in two cookies. The question is, what is the best way for me to log users in if they have the two cookies on their system? I was thinking that maybe, before I run the session_start() function, I could do an if statement to check to see whether the cookies exist. If they do exist, I was thinking that I could use the header() function to send them to my login page(login.php for example). This page would be the same page that processes the login form and logs them in, and it would check to see whether the cookies are set, and if they are, check the data in them against data in my mysql database. If their data is correct, then the values are registered into the session and they're logged in, and automatically sent back to the main page(index.php).

    What do you guys think of that? Is this a good way to log users in with cookies, or is there another way that you guys recommend. I've done this before with another site, but it doesn't use the same method for logging users in with cookies.
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource

  2. #2
    SitePoint Guru dragonhawk's Avatar
    Join Date
    Apr 2002
    Location
    Melbourne
    Posts
    707
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That's what I would have done

    Am actually planning for it myself sometime in the near future

  3. #3
    ********* Celica Lover Coomer's Avatar
    Join Date
    Apr 2002
    Location
    Not worth the drive
    Posts
    474
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Anyone else have any comments? I just want to make sure that the way I'm doing it will work, because I'll probably write the code once I'm home from work today.
    + Celica =
    6G Celicas :: My '94-99 Toyota Celica resource


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •