CodeIgniter Forums
Blank Screen using sessions... - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Blank Screen using sessions... (/showthread.php?tid=8450)



Blank Screen using sessions... - El Forum - 05-18-2008

[eluser]jenie_net[/eluser]
Hi all!

I've got a controller Login.php
Code:
<?php

class Login extends MY_Controller {

    function Login()
    {
        parent::MY_Controller();
        $this->load->helper('security');
        $this->load->helper('form');
        $this->load->model('User_model');
    }
    
    function index()
    {
        $this->_header_ajax('Authentication required:');
        $this->load->view('public/login_view');
        $this->_footer();
    }


    function authenticate(){
        $data = array(
               'username' => $this->input->post('username', TRUE) ,
               'password' => $this->input->post('password', TRUE),
                    );
        $result=$this->User_model->authenticateUser($data);
        if ($result != NULL ){
            /*    Settare gli attributi di sessione     */    
            /* $res_sess = array(
                                            'logged_in' => TRUE
                            'role' => $result->role;
                           );
            $this->session->set_userdata($re_sess); */        
            

                   redirect('protected','refresh');
        }
        else{
            $this->index();
        }
        
    }
    
}
?>


This works well until i leave comments on this parts
Code:
/* $res_sess = array(
                                            'logged_in' => TRUE
                            'role' => $result->role;
                           );
            $this->session->set_userdata($re_sess); */


If i delete comments, i have a blank screen while attempting to

http://mysite.com/index.php/login

(The strange thing is that i'm in index() while i call login without parameters...
and the code is in authenticate function..)

Any help?

Thanks in advance...

Stefano Marino


Blank Screen using sessions... - El Forum - 05-18-2008

[eluser]gtech[/eluser]
Code:
$res_sess = array('logged_in' => TRUE,
                  'role' => $result->role);

Hello,

there should be a comma after the TRUE bit in the array and you should not need the semi colon after the $result->role bit.. those php errors may cause your blank screen. If you have syntax errors in your code this may stop the controller from loading properly and hence why you see problems when accessing the index method.


Blank Screen using sessions... - El Forum - 05-18-2008

[eluser]jenie_net[/eluser]
Incredible...i'm so stupid!

Thanks a lot, and sorry!!

Stefano Marino