2010-11-22 17 views
0

KontrolörCakePHP'de oturumu yazılamaz

function login() { 
    // Don't show the error message if no data has been submitted. 
$this->set('error', false); 

    // Does not render the view 
    $this->autoRender = false; 

// If a user has submitted form data: 
if(!empty($this->data)) { 
    $someone = $this->Student->findByStudentEmail($this->data['Student']['email']); 
    if(!empty($someone['Student']['student_pwd']) && $someone['Student']['student_pwd'] == $this->data['Student']['password']) { 

     $this->Session->write('eyeColor', 'Green'); 
     $this->Session->write('Student', $someone['Student']); 

     // session information to remember this user as 'logged-in'. 
     echo "success"; 

    } else { 
     echo "failed"; 
    } 
} 
function main(){ 
    $this->set('students', $this->Student->find('all')); 

    $this->set('eyeColor', $this->Session->read('eyeColor')); 

    // Render the specified view 
    $this->render('/pages/main'); 
} 

görünüm main.ctp

<?php print $eyeColor; ?> 
Bu kılavuzda var
+1

Herhangi bir hata mesajı alıyor musunuz? Oturumları doğru şekilde yapılandırdınız mı? –

+0

Oturum bileşenini denetleyiciye dahil ettiniz mi? – JJJ

+0

@Juhana: Oturum bileşenini denetleyiciye dahil etmeniz gerekmez, otomatik olarak yüklenir. – dhofstet

cevap