phpsessionextjspaginationgridpanel

ExtJS: store, pagingToolbar and PHP session expire


Let's imagine you are on a page with an ExtJS grid with a pagingToolbar. Let's imagine that you remain on this page for a while and that during this time your PHP session expires. When you hit "Next page" or "reload" on the grid, the call to the server will fail since it will answer with something informing you that you are not allowed to get the information (since your session has expired).

How can you handle that in the gridPanel in order to avoid it to get stuck? I hope this was clear enough..

Bye!


Solution

  • You'll need some sort of heartbeat mechanism, which means that you must periodically send an AJAX call to your server to keep the PHP session alive. If you're using Ext.direct you can simply make use of the Ext.direct.PollingProvider which is by far the most convenient way to implement such a heartbeat. If you're not using Ext.direct you can use Ext.TaskMgr or Ext.util.TaskRunner to call a function periodically in which you can simply issue an AJAX request.

    The implementation details are left to the OP.