tags:

views:

156

answers:

2

I'm having difficulty accessing a $_SESSION variable.

I have session_start() at the beginning of the file.

I'm using jQuery uploadify and it calls a php backend file, which can't access $_SESSION variables, although other files outside could.

Could it have something to do with the way that flash (jquery uploadify) is calling the php?

Does anyone know how to circumvent this?

UPDATE: included session_id in the url but it didnt work.

$('#image_upload').uploadify({
    'uploader':     '../../frontend/jquery/plugins/uploadify/swf/uploadify.swf',
    'script':       "controllers/image_upload.php?SID='.session_id()'",
    'fileDataName': 'upload',
    'method':       'POST',
    'multi':        'true',
    'fileDesc':     'tseting',
    'fileExt':      '*.jpg; *.jpeg; *.png',
    'sizeLimit':    '100000000',
    'buttonText':   'Ladda upp bilder',
    'auto':         'true'
});

EDIT: i think i know what the problem is.

in the header information with livehtmlheader in FF it shows an error message:

 HTTP/1.x 404 Not Found

while the other regular page requests shows

 HTTP/1.x 200 OK

someone knows how to solve this?

EDIT: sorry i've had wrong. it was not cause by 404, that was a request to another file. there is NO request when posting with uploadify! no html header is sent. i think it uses another approach to get the php file with flash (uploadify.swf).

so there is no way of sending that sessid to my php file now i guess:( have to find some other way around

+2  A: 

In certain browsers (firefox iirc) "special" calls, such as file uploads and amf do not always send along the session cookie. The most practical way to sidestep this is to set it as a flashvar when embedding the flash and manually send it along with your request.

grapefrukt
don´t quite understand your solution. is it easy to implement and are there any tutorials?
weng
A: 

Try adding manually "?SID=".session_id() to the URL.

Artjom Kurapov
tried that but it didnt work. look at my updated post
weng
JavaScript is doing the request, not PHP. So `session_id` is not available.
Gumbo
OP, you are missing opening and closing PHP tags in your implementation of Artjom's hint: `<? ?>`
Pekka