Sessions and uploadify

Uffo picture Uffo · Aug 16, 2009 · Viewed 19.6k times · Source

I'm using uploadify, and i can't set sessions in my php files, my script looks like this:

    $("#uploadify").uploadify({
        'uploader'       : '/extra/flash/uploadify.swf',
        'script'         : '/admin/uploads/artistsphotos',
        'scriptData'     : {'PHPSESSID' : '<?= session_id(); ?>'},
        'cancelImg'      : '/images/cancel.png',
        'folder'         : '/img/artists',
        'queueID'        : 'fileQueue',
        'auto'           : false,
        'multi'          : true,
        'onComplete'     : function(a, b, c, d, e){

        },  
        'onAllComplete': function(event,data){
            $bla = $('#art').find(':selected',this);
            $fi  = $bla.val();
             $.ajax({
               type: "POST",
               url: "/admin/uploads/artistsphotosupload",
               data: "artist="+$fi,
               success: function(msg){
                 console.log(msg);
               }
             });
     }
});

And in php if i try:

$_SESSION['name'] = 'something';

I can't access it in another file.and i have session_start(); activated Any solutions?

Answer

HB. picture HB. · Dec 18, 2009

you cannot solve this because uploadify has own session ID which is created by flash player. In other words the flash player access the uploadify script as a new user and gets a new session. The only way you can solve this is to pass current page session_id through post to the uploadify script.