Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sessions and uploadify

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?

like image 980
Uffo Avatar asked Aug 16 '09 16:08

Uffo


2 Answers

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.

like image 135
HB. Avatar answered Oct 22 '22 03:10

HB.


Usually the session ID won't be read from POST. You could do this:

$_COOKIE['PHPSESSID'] = $_POST['PHPSESSID'];
session_start();
like image 30
Greg Avatar answered Oct 22 '22 02:10

Greg