CakePHP'de oturumu yazılı olamaz

0 Cevap php

Controller

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');
}

view main.ctp

<?php print $eyeColor; ?>

0 Cevap