⚠ 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

"add record" with session



archer8
  • profile picture
  • Member

Posted 12 June 2012 - 14:45 PM

Hey There,

I'm actually not even sure if this is my problem (hoping it is though, as it seems to work without the problem mentioned below).

What I'm encountering is "add record" will fail when I include it in a login system that creates a session and then checks the user is logged in.

It will just tend to load forever and do nothing.


public function __construct() {
session_start();
parent::__construct();
if (!isset($_SESSION['username'])) {
redirect('admin');
}
$this->load->database();
$this->load->helper('url');
$this->load->library('grocery_CRUD');
}



public function database() {
$crud = new grocery_CRUD();
$crud->set_theme('datatables');
$crud->set_table('table_name');

$crud->required_fields('lastName');
$output = $crud->render();
$this->load->view('database', $output);
}


If I use the exact same table and function without the session it works fine - I can view and add data.

Any pointers on what I can do to get this working?

xxaxxo
  • profile picture
  • Member

Posted 13 June 2012 - 05:30 AM

Why do you use session_start() at all? it's a CI thing - just put your session class in autoload and do something like this:

public funcion __construct() {
parent::__construct();
if($this->session->userdata('username')=='admin') {
redirect('admin');
}
$this->load-> blablabla ......
}