## Aurigma Image Uploader 7.0.15

# Maintaining Sessions and Authentication in PHP

- Collapse All Sections
- See Also
- Language Filter ( all languages )

If you are going to utilize Image Uploader in non-Internet Explorer browsers (Firefox, Safari, and etc), you should take care about keeping your session and authentication cookies saved if they are used. The fact is that Image Uploader does not send cookies in output requests in non-Internet Explorer browsers by default and, therefore, session and authentication tickets are lost during the upload. To work around this problem you may employ special facilities provided either by Image Uploader PHP or Image Uploader JavaScript. Let us consider how to use them.

## Using Image Uploader PHP Library

If you use Image Uploader PHP, session and authentication information will be automatically passed to the upload request. If you are unfamiliar with Image Uploader PHP, please, see the Quick Start with Image Uploader PHP topic.

## Using Image Uploader JavaScript API

If you prefer not to use Image Uploader PHP, then you should add cookies to the upload request manually via the Image Uploader JavaScript. To do it, use the metadata.addCookie(String) method which accepts cookie in the following format: "cookieName=cookieValue". The most convenient place to call this method is the BeforeUpload event handler, because this event fires when the upload is about to be started.

### JavaScript

    function beforeUploadHandler(){
        var u = $au.uploader('Uploader1');
        u.metadata().addCookie('PHPSESSID=<?=$_COOKIE["PHPSESSID"]?>');
    };

    var u = $au.uploader({
        id: 'Uploader1',
        events: {beforeUpload: beforeUploadHandler},
    });
    u.writeHtml();

## See Also

### Reference

- metadata Class
- Uploader Class
- BeforeUpload Event

### Manual

- Quick Start with Image Uploader PHP
- Using JavaScript API