CodeIgniter 2 + Sparks + PHP ActiveRecord Part 3: Login

Loading...

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

Uploaded by on Aug 17, 2011

In this screencast we use the User model that we previously created to allow the user to login. We create a controller extension and we discuss some best practices for object-oriented PHP.

Be sure to watch in HD.

For more screencasts and articles check out http://heybigname.com

Category:

Education

Tags:

License:

Standard YouTube License

  • likes, 0 dislikes

Link to this comment:

Share to:

Uploader Comments (ShawnMcCool)

  • ShawnMcCool, I seem to be getting PHP error when implementing this, a fault of the 404_override feature in CodeIgniter. When I go to something like mysite.com/welcome/doesnotexis­t, if the welcome controller does exist, and the doesnotexist method does not exist, the desired 404 page doesn't show up, and instead nasty PHP errors are outputted. Have you experienced this problem and what would be the best way to fix it? Also, why do you use the 'var' keyword? Isn't that depreciated in PHP5?

  • @skcin7 Yea, I'm not using the var keyword anymore. Instead just using public, protected, or private. Despite the fact that it's not going to break anything, it just feels more like real programming. Check the CI manual for the 404 override information and/or post your errors. It's best to post them on my blog since I rarely check my youtube videos.

  • Nice tutorial, one question though why don't you return the current user on successful login instead of just the id? That way you can save that extra query when you store the user data on the session.

  • @vengiss It's generally not a good idea to store an AR object in sessions. Not only is there a limit to the amount of session data that could be stored but objects can lose some more advanced properties when serialized in a manner such as this. Not to mention that an admin may want to alter the user record.

    Either way, there's really little to no value in saving that extra query as its result is typically cached.

  • @vengiss It's not advisable to store complex data-types in this manner. It's fine if you just have a simple array or object. But, if you want to use references to other objects or anything like that then it can cause problems.

see all

All Comments (7)

Sign In or Sign Up now to post a comment!
  • @ShawnMcCool That's good to know, thanks!

  • Thanks for the great tips. You're very fast at explaining everything; but atleast you don't go over the obvious things 50 times as if the people watching are idiots like some people do! Looking forward to some more videos in the future.

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