Welcome Guest, Not a member yet? Register   Sign In
Problem with Pagination Killing session userdata
#1

[eluser]gazza7364[/eluser]
Hi

I have a problem with pagination, which is destroying session userdata, then sending me back to the logon page.

Everything works when I press next and previos pages until I go back to the first page. This then destroys my session userdata, sending me to the logon page.

Any ideas?





Controller

Code:
function display(){
// load pagination library

$this->load->library('pagination');
$this->load->library('table');;
// set pagination parameters
$config['base_url']='http://localhost/blog/index';
$config['total_rows']=$this->blog_mysql->mycount();
$config['per_page']='3';
$config['num_links']='3';
$config['last_link'] = 'Last';
$config['first_link'] = 'First';
$config['full_tag_open'] = '<div class="pagination">';
$config['full_tag_close'] = '</div>';

$this->pagination->initialize($config);

//$data['result'] = $this->db->get('blog', $config['per_page'], $this->uri->segment(3));
$data['result'] = $this->blog_mysql->getAll($config['per_page'], $this->uri->segment(3));

echo print_r($this->session->all_userdata());

$this->load->view('blog/pages', $data);

}


Model



Code:
function getAll($num1, $num2)
{

$id = $this->session->userdata('user_id');
$this->db->where('user_id', $id);
$this->db->order_by('date desc');
$query = $this->db->get('blog',$num1, $num2);
  
if ($query->num_rows() > 0)
{
     foreach ($query->result() as $row)
     {

  $data[] = $row;
   }
  
}
   return $data;
}
#2

[eluser]gazza7364[/eluser]
Hi again

I've just been looking at the first page link which is know /blog/index (after changing from blog/display) , when you click on this link it logs you out, I also have a link on the same page, which points to localhost/blog , which in affect is the same link, but this works. I know pagination, is making the link on the first link, but it will be loading the same page and data.

I still can't work it out.
#3

[eluser]gazza7364[/eluser]
Help anyone
#4

[eluser]InsiteFX[/eluser]
Maybe:
Code:
$config['base_url']='http://localhost/blog/display';
#5

[eluser]gazza7364[/eluser]
[quote author="InsiteFX" date="1337611280"]Maybe:
Code:
$config['base_url']='http://localhost/blog/display';
[/quote]

Hi

I've tried as suggested still the same. I also renamed the display controller to index but still to no avail.

I've just downloaded a fresh install of CI and moved the blog to this install.
I renamed the blog controller to myblog and everything is working, if I rename it back to blog every thing works fine until I click the first page link, I then get a 404 Page Not Found displaying. so it seems it something to do with the controller being named blog.

update

After further investigation, it looks like it was down to my default route controller, which was my logon page, I set this to a different controller and everything seems fine, even with the controller being named blog.

Thanks for your reply.




Theme © iAndrew 2016 - Forum software by © MyBB