11.30 php saved
Oshuma
Tags add more
Login and authentication.  
Note
Following the User Auth tutorial pretty much verbose.
http://manual.cakephp.org/appendix/simple_user_auth
  1. /* UsersController */
  2.     function login() {
  3.         // Don't show the login error by default.
  4.         $this->set('login_error', false);
  5.  
  6.         // If a User has submitted form data.
  7.         if ( !empty($this->data) ) {
  8.             // Attempt to find a User with the given login name.
  9.             $user = $this->User->findByLogin($this->data['User']['login']);
  10.             // Check for a correct password.
  11.             if ( !empty($user['User']) &&
  12.                 $user['User']['password'] == md5($this->data['User']['password']) ) {
  13.                 // Login successful, set the session and redirect.
  14.                 $this->Session->write('User.id', $user['User']);
  15.                 $this->flash("You have been logged in.", '/');
  16.             } else {
  17.                 // Login failed, flag the error message.
  18.                 $this->set('login_error', true);
  19.             }
  20.         }
  21.     }
  22.  
Parsed in 0.051 seconds, using GeSHi 1.0.7.14

Modify this Paste