User Authentication in PHP (part 2)

Loading...

Sign in or sign up now!
Alert icon
Upgrade to the latest Flash Player for improved playback performance. Upgrade now or more info.
246 views
Loading...
Alert icon
Sign in or sign up now!
Alert icon

Uploaded by on Apr 27, 2011

This small series will teach you the basics of authenticating users with PHP. By the end you'll be able to secure passwords, check user login info and handle user pages with ease.

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (BaylorRae)

  • You have misapplied the singleton pattern here. When you call find_by_username a second time, the call to instance() will return the same user as the first call - and then you overwrite the values. e.g. run

    $user1=User::find_by_username(­"Fred");

    $user2=User::find_by_username(­"John");

    print_r($user1);

    print_r($user2);

    And you'll get the same values (John) for both users. You need to return a New User for each call.

  • @dave28lax That is a great point that I missed. Thank you for posting this as I never considered getting two users at the same time.

  • Nice video dude. Why do you use 'static' for functions and variables? I don't understand it. :P

  • @TeenAviator The concept I used their is called the singleton method. It allows the script to only use one instance of the User class. So instead of initializing or "__construct"ing the class x amount of times, we only do it once.

    For more information and tutorials google "singleton in php" and look for a post on talkphp.com and php.net under "PHP: Patterns" as the title.

see all

All Comments (5)

Sign In or Sign Up now to post a comment!
  • Cool. Thanks for the info. :) What do you use 'static' for?

Loading...

Alert icon
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