4

Im uploading files with the uploadify plugin. the PHP SESSION is lost during upload, is there a way to restore the session? Perhaps by its id?

waterschaats
  • 994
  • 3
  • 18
  • 32
  • What he is talking about is a common problem with flash based uploaders. They don't automatically get the cookie that identifies the session from the browser so you have send the session id manually. – Alec Gorge Mar 18 '11 at 13:30

1 Answers1

14

Yes. You need to add an option to uploadify:

$('#upload').uploadify({
    'scriptData':{'session_name':"<?php echo session_id(); ?>"}
});

And you need to add this to your PHP:

<?php
session_id($_POST['session_name']);
session_start();
?>

Then everything will be as expected.

Alec Gorge
  • 17,110
  • 10
  • 59
  • 71
  • 1
    You need to call session_id($_POST['session_name']) before calling session_start(). – Jody Mar 18 '11 at 13:57
  • @Jody you are correct, thanks. @waterschaats Since it is the correct answer, click the checkmark outline next to the question to confirm it as such. – Alec Gorge Mar 18 '11 at 23:13