Gets or sets cookies which should be added to the upload request.
$au.uploader({ metadata: { //...other params... cookie: "", //...other params... } })Get/Set Value at Runtime
$au.uploader('uploaderID').metadata().cookie(value); value = $au.uploader('uploaderID').metadata().cookie();
Most browsers, such as Firefox since version 2.0.0.5 support HTTP-only cookies. They make it impossible to read these cookies using JavaScript. It increases security and prevents your site from cross-site scripting attacks.
When Image Uploader prepares the POST request before uploading it to the server, it extracts all cookies downloaded along with the page that hosts Image Uploader. To get cookie, Image Uploader uses the same object model as you do in JavaScript (as if you use document.cookie
). However, the browser does not allow Image Uploader to get HTTP-only cookies. That is why when you post files to the server, it does not get such cookies.
Image Uploader ASP.NET and Image Uploader PHP automatically pass the session and authentication information to the upload request.
However, if Image Uploader JavaScript is used, you should add cookies to the upload request manually. To do this, add each cookie you need to preserve via this method as it is shown below.
Preserving cookies in ASP.NET:
var u = $au.uploader({ id: 'Uploader1', metadata: { cookie: 'ASP.NET_SessionId=<%=Page.Session.SessionID%>;' + '<%=FormsAuthentication.FormsCookieName%>=' + '<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>' } }); u.writeHtml();
Preserving cookies in PHP:
var u = $au.uploader({ id: 'Uploader1', metadata: { cookie: 'PHPSESSID=<?=$_COOKIE["PHPSESSID"]?>' } }); u.writeHtml();