Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Ajax file upload session crash
  • Hi,

    I'm using Jquery Ajax Forms plugin to upload images via ajax.


    $('#upload_photos').ajaxSubmit({
        dataType: 'json',
        resetForm: true,
        success: function(data){
        
        }
    });

    I have ajax rest controller, that validates post filed "tmp_id" before file upload.

    class Controller_Ajax extends Controller_Rest {
        public function post_upload_photo(){
            if(Input::post('tmp_id') == Session::get('tmp_id')){
                // File uploading
            }
        }
    }

    The problem is, if I'm uploading several images one by one, some of the requests are pending for about 20 minutes and than return an empty response with crashing all session variables.

    Don't know how to fix it, need help.

    Thanks
  • Any ideas why the session crashes and so long "pending" request?

    Thanks
  • It might be an issue with session key rotation.

    By default, as a security measure, the session key rotates every 5 minutes. The system has a recovery mechanism to recover from a just-expired key, but it can't look further back (that would defeat the purpose).

    So after 10 minutes, the session key used in the ajax request is no longer valid. When the process then wants to access or update the session, it will find no session data, since the key it has is no longer valid.

    So try changing the session key rotation time to 30 minutes or so, or use a different mechanism than the session.
  • I've already play with session key rotation, but nothing happened. 

    I've tried Plupload instead of Jquery Forms and the same error. It seems this error only appears in Safari (Chrome, FF, IE is okay). And I think it doesn't depend on the Session (I've omitted session variable validation).


  • Ok, thanks for the feedback.
  • If I remember right Safari had problems with cookies and sessions. Do a Google search on cookie problems.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion