Сессия CakePHP не может быть написана - PullRequest
0 голосов
/ 22 ноября 2010

Контроллер

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

вид main.ctp

<?php print $eyeColor; ?>

1 Ответ

0 голосов
/ 22 ноября 2010
<?php echo $session->read('eyeColor') ?>

Это в руководстве: http://book.cakephp.org/view/1466/Methods

Правда, не совсем понятно. Может быть, я отправлю обновление.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...