views:

514

answers:

3

I am using CodeIgniter to build an application. The app is having many AJAX requests on setTimeoutInterval, which fires every few seconds.

Now the situation is: If a user has a page kept open. The page sends ajax requests at intervals. At that point of time I have updated my application in the server.

So I want to keep a version check, which notifies the user if the app has been upgraded in the meantime.

I am using CodeIgniter to build this application.

I am writhing a "post_controller" hook which will check the version in request header and the current version in the app. If something is wrong. It will send version mismatch response and exit.

Now I am able to do everything but can not stop further processing. If I am giving exit() in this particular situation, the view response is not being sent.

I can use simple echo/print. But CodeIgniter view is not sending the response if I am giving a die()/exit.

A: 

Not sure it would work, just throwing it out there:

Would it be possible to pass your mismatch detection to your AJAX function and then call a javascript window.location redirect to a standard "version updated" error page?

Andy Copley
A: 

Hi,

Because codeigniter stores sessions in database, you can always know who is connected to app when you are updating your server.

when to do verification of version:

  • Everytime someone create one new session

When you update the system:

  • Put one flag in the config/config.php like updated=true, then all sessions actives will be forced to do validation.

Regards, Pedro

Pedro
+1  A: 

"Now I am able to do everything but can not stop further processing. If I am giving exit() in this particular situation, the view response is not being sent.

I can use simple echo/print. But CodeIgniter view is not sending the response if I am giving a die()/exit."

You are being unclear as to what you want to do on version mismatch - exit, or send a response? Just do an exit('NEW_VERSION_AVAILABLE'), detect that response in your JS code, and reload the page.

If you want the request to be ignored competely, you should do the same in a pre_controller hook.

Joel L