I am having an anooying issue when trying to restore a session.
I am using the Javascript Uploadify / swfupload file upload solution, which kills the session during the upload. (this appears common for swfupload)
Everywhere on the web I am reading the solution is to send the current sessionid along with the form to the upload script, and then there restore the session by settings its ID again, sounds solid enough in theory.
The current code is along the line of the code shown below, in this case the current document is the same as where the file is submitted to (upload.php), Ive also tried to post to another page, no luck there either.
<?php
error_reporting(-1);
$formposted=false;
if(isset($_POST['session_name'])){ //is set, test have proven so
$formposted = true;
session_id($_POST['session_name']);
}
session_start();
if(!$formposted){
$_SESSION['sessionvar'] = 'hello world';
}else{
echo $_SESSION['sessionvar']; //always empty
}
?>
<script type="text/javascript">
$(document).ready(function() {
$("#uploadify").uploadify({
'uploader' : '/uploadify/uploadify.swf',
'script' : '/upload.php',
'cancelImg' : 'uploadify/cancel.png',
'folder' : 'uploads',
'queueID' : 'fileQueue',
'scriptData': {'session_name': '<?php echo session_id(); ?>'},
'auto' : true,
'multi' : true
});
});
</script>
I'd sincerely appreciate it if anyone can assist me in clearing up this problem, as I'm getting slightly insane over this.
Many thanks in advance.
Regards,
Eelco