0

i have a controller and a view indicated as below which works perfect for some time, but after some requests are made to the server(i.e. keeps reloading every one second) it will fail on this line

 if (!$this->tank_auth->is_logged_in()) 

for no reason, i don't know weather it is congested or ...

when i try to debug the client code in firebug and hold a put a break point on this line

  $('#buy_reload').load('buy/reload'); //And press f8 every time

it woks like charm what is the problem? load?

Z controller

class Buy extends CI_Controller
{
function __construct()
{
    parent::__construct();

    $this->load->helper('url');
    $this->load->library('tank_auth');
    $this->load->model(array('tank_auth/users','players','cash','inventory','items','shopping_cart','purchases','processing'));
}

function reload()
{
    if (!$this->tank_auth->is_logged_in()) { 
        redirect('/auth/login/');
    } else {
            //do those stuffs
           }

}
}

a script inside Z view

  <script>
   setInterval(function() {
   $('#buy_reload').load('buy/reload');
   }, 1 * 1000);
  </script> 
jspeshu
  • 1,211
  • 3
  • 12
  • 20

1 Answers1

2

I had a similar problem with Tank Auth and CodeIgniter 2.1 . There seems to be an issue with sessions and Ajax calls. The following links will help you

http://ellislab.com/forums/viewthread/199753/#962141

http://ellislab.com/forums/viewthread/203821/#951378

The problem is in the sess_update function of the session class, that generates a new session_id after X seconds. Every page have a session_id, if the session_id expires before the ajax call is made, that call will fail.

St0iK
  • 628
  • 3
  • 10
  • it is not exactly with the ajax calls only as i see but your links provided the answer and explanation of the problem here http://www.hiretheworld.com/blog/tech-blog/codeigniter-session-race-conditions Thanks – jspeshu Jan 16 '13 at 07:56