Alert icon
We're changing our privacy policy. This stuff matters.  Learn more  Dismiss

PHP Tutorials: 'Remember me' style Login System using Cookies and Sessions (Part 6)

Loading...

Sign in or sign up now!
10,519
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Aug 8, 2009

Visit the forum for help!
http://phpacademy.info/forum

Follow on Twitter!
http://twitter.com/phpacademy

Create a cookie/session based login system with a 'remember me' checkbox to keep your user logged in for next time they visit.

  • likes, 1 dislikes

Link to this comment:

Share to:

Uploader Comments (phpacademy)

  • would the

    setcookie("username","",time() work with =0 instead of -7200?

    And is it possible to set it to unlimited when logging in?

  • Not sure what you mean for your first question, but for your second question: If you just don't specifiy the third parameter it will exist until the user clears their browser cookies.

Top Comments

  • Hi!!! Alex...your tutorials on php are d best!!

    Can you do a tutorial on how to add a download part for my site???

    Suppose i have some stuff i want my users to download how can i do dat using php & ftp???

    It will be very helpful for students like me...

    Thnx...& keep those tutorials coming :-)

  • I have spent a lot of money to study php but all fail ,bcoz of my fucking institution

    they provide theory only and the applications are not on their syllabus.Thanks Alex you are my only PHPguru ..Thanks a lot for your tutorials...keep going 

see all

All Comments (42)

Sign In or Sign Up now to post a comment!
  • really very helpful videos

  • Thanks:D This help me very much! 8-D

    

  • hi alex, thank you for all you've done!!

    but you forgot to the part that is relating to showing a message "incorrect pass/username combination." i tested by entering a wrong password, the message popped up just fine!! but if when i entered a wrong username it didn't do anything except resetting the fields.

    please help i know it's just a minor error but i still need it to be perfect!! :)

  • @SnowFortcom Np. You can do it much better than that though.

  • @jimjimmy1995 THANK YOU SO MUCH!

  • sir..!! plz :((

    help, cannot logged in !! :'((

  • @federigaalin No problem, I've had to change a lot of alex's code to get my login working. I wanted it so that it was included onto every page not on its own page. You can see it here: fmstudios. comlu. com/register/ If you want help with doing it like I have just message me. : )

  • @jimjimmy1995 whoa, thank you very very much.

  • @federigaalin if ( isset($_COOKIE['username']) ) { $username = $_COOKIE['username'];

    } else if ( isset($_SESSION['username']) ) { $username = $_SESSION['username'];

    }

    echo "Welcome, ".$username."!";

  • hello alex , i have a question. If a user logs in with cookies, you will set setcookies instead of $_SESSION['username']. but if in the member area, instead of "you're in" i want to write the user's name it can't be done with $_SESSION['username'] because i set setcookie. how can i do that?

Loading...

0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more