Uploadify上传Session丢失问题

只要在使用uploadify 上传的时候,只要将sessionId传过去就可以了。


在jsp中如何取sessionId:${pageContext.session.id}

<input type="hidden" id="sessionId" value="${pageContext.session.id}" />


$("").uploadify({
'formData'  : {'ASPSESSID':$("#sessionId").val()}
});



uploadify的官网解释:http://www.uploadify.com/documentation/uploadify/using-sessions-with-uploadify/

Using Sessions with Uploadify

In Uploadify, the Flash file is what communicates with the backend script.  Because of a bug in Flash, the session cookie is not picked up by the Flash file.  To circumvent this, you will need to pass the session data via the formDataoption.  To do this in PHP, use the following code when initializing Uploadify on the front-end page:

$('#file_upload).uploadify({
    // Your normal options here
    formData : { '<?php echo session_name();?>' : '<?php echo session_id();?>' }
});


This will send the session ID as the value of a post (or get, depending on the method you’ve set)  parameter to the server-side upload script (uploadify.php) with a key of whatever your session_name is.

At the beginning of your uploadify.php script, you can use the following code to load the proper session:

 This will start the proper session and allow you to use any session variables as expected.

For an extra layer of security, you can call session_regenerate_id() in some PHP code that is fired when your uploads are done.


你可能感兴趣的:(java,java,java,session,session,session,uploadify,uploadify)