---
title: "metadata.cookie Property  ActiveX/Java Uploader JavaScript"
canonical: https://www.aurigma.com/docs/us8/JA_P_J_$au_metadata_cookie.htm
product: "Upload Suite 8"
---

# metadata.cookie Property ActiveX/Java Uploader JavaScript

Supported browsers: ![Firefox](https://www.aurigma.com/docs/us8/icons/firefox.png)![Google Chrome](https://www.aurigma.com/docs/us8/icons/chrome.png)![Safari](https://www.aurigma.com/docs/us8/icons/safari.png)
 
Gets or sets cookies which should be added to the upload request.

## Syntax
 
```
$au.uploader({
    metadata: {
        //...other params...
        cookie: "",
        //...other params...
    }
})
```

```
$au.uploader('uploaderID').metadata().cookie(value);
value = $au.uploader('uploaderID').metadata().cookie();
```
 
### Property Value
 
Type: **String**
 
The cookie string to attach it to the upload request.
 
Default value is **""**.

## Remarks
 
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 Java Uploader prepares the POST request before uploading it to the server, it extracts all cookies downloaded along with the page that hosts ActiveX/Java Uploader. To get cookie, Java Uploader uses the same object model as you do in JavaScript (as if you use `document.cookie`). However, the browser does not allow Java Uploader to get HTTP-only cookies. That is why when you post files to the server, it does not get such cookies.
 
**Note** 
ActiveX/Java Uploader ASP.NET and ActiveX/Java Uploader PHP automatically pass the session and authentication information to the upload request.
 
However, if ActiveX/Java 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.

## Example
 
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();
```

## See Also
 
### Manual
 
- [Maintaining Sessions and Authentication in ActiveX/Java Uploader ASP.NET](https://www.aurigma.com/docs/us8/maintaining-sessions-and-authentication-in-aspnet-iu.htm.md)
- [Maintaining Sessions and Authentication in ActiveX/Java Uploader PHP](https://www.aurigma.com/docs/us8/maintaining-sessions-and-authentication-in-php-iu.htm.md)
