1

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

12
  • "Can't access" is somewhat vague. What's the error/notice message? Commented Jan 15, 2010 at 15:38
  • 1
    Use LiveHTTPHeaders to inspect the HTTP request jQuery is sending. Is it including the PHPSESSID cookie? Commented Jan 15, 2010 at 15:39
  • Your XMLHTTPRequests are probably missing the session ID. Either in the URL or in a cookie. Commented Jan 15, 2010 at 15:40
  • @frank farmer: could you give me some more detail, where and what to type? Commented Jan 15, 2010 at 17:02
  • How do you carry the session ID along? In the URL or with a cookie? Commented Jan 15, 2010 at 17:14

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

1 Comment

don´t quite understand your solution. is it easy to implement and are there any tutorials?
0

http://www.uploadify.com/forums/discussion/606/io-error-php-session/p1

Comments

0

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

2 Comments

JavaScript is doing the request, not PHP. So session_id is not available.
OP, you are missing opening and closing PHP tags in your implementation of Artjom's hint: <? ?>

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.