0
votes

I'm trying to implement AD authentication in my php application however I'm having troubles pulling information from session userdata and I'm not sure why.

The authenication works as I'm able to login with AD credentials and display WIN, but I cannot display session data.

I'm trying to use this lightweight library: Auth_AD Codeigniter Library

Auth Controller:

public function login()
{


    // read the form fields, lowercase the username for neatness
    $username = strtolower($this->input->post('username'));
    $password = $this->input->post('password');

    // check the login
    if($this->auth_ad->login($username, $password))
    {           

        $data['udcn'] = $this->session->userdata('cn');

        $this->load->view('user/win', '$data');
    }
    else
    {

        $this->load->view('user/lose');
        // user could not be authenticated, whoops.
    }
}

VIEW:

  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
   <head>
   <title>WIN</title>
   </head>
    <body>
         <?php echo $udcn['cn']; ?>
    </body>
   </html>

Any help would be greatly appreciated!

3
Take the single quotes off the $data. Should be $this->load->view('user/win', $data); - ourmandave
this fixed it! I've been staring this computer to long... thank-you. I should have caught that. - dotmiikee

3 Answers

0
votes

On the view

<?php echo $udcn; ?>

remove the ['cn']

Make sure you have set your session config setting's OK in the config.php

Example

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH . 'cache/session/';
$config['sess_match_ip'] = TRUE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = TRUE;
0
votes

Thanks to ourmandave!

Take the single quotes off the $data. Should be $this->load->view('user/win', $data);

0
votes

Change this line $this->load->view('user/win', '$data'); into $this->load->view('user/win', $data); and access it in your view as just <?php echo $udcn; ?>