⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Security Problem



dontako

dontako
  • profile picture
  • Member

Posted 14 November 2012 - 18:48 PM

Hello, I have a little problem with the sessions.
I am using codeigniter session library, and that's how it works:


function _example_output($output = null)
{
if($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$output->ses_data = array('username' => $session_data['username'],
'id' => $session_data['userid'],
'permisos' => $session_data['userperms']);
$this->load->view('home_view.php',$output);
}
else
{
//If no session, redirect to login page
redirect('login/index/', 'refresh');
}
}




It works fine, when I try to access from another browser without being logged in, the problem is when I refer to Ajax_list, for example if I write

[b]mysite.com/panel/users/[/b]

Not allow me access because it is a private area, so far so good.

but ....

[b]mysite.com/panel/users/[color=#ff0000]ajax_list[/color][/b]

This shows the list! and I'm not logged in, any suggestions for handling sessions in this case?

Greetings!

victor

victor
  • profile picture
  • Member

Posted 14 November 2012 - 19:15 PM

HI! Don't use the security code in that function!
You should to use it before _example_output, for example in the __construct();




class test extends CI_Controller
{
var $ses_data;
function __construct()
{
parent::__construct();

if ($this->session->userdata('logged_in'))
{
$session_data = $this->session->userdata('logged_in');
$this->user_data = array('username' => $session_data['username'],
'id' => $session_data['userid'],
'permisos' => $session_data['userperms']);
}
else
{
redirect('login/index/', 'refresh');
}
}

function manager()
{

//other code
$output = $crud->render();
$output->ses_data = $this->ses_data;
$this->load->view('home_view.php',$output);
}

}

dontako

dontako
  • profile picture
  • Member

Posted 14 November 2012 - 19:30 PM

Thank you! <3