## Aurigma Image Uploader Flash 1.0

# Preserving Sessions and Authentication Tickets Passed in Cookies

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

If you are going to utilize Image Uploader Flash in non-Internet Explorer browsers (Firefox, Safari, Opera, etc), you should take care about keeping your session and authentication cookies saved if they are used. The fact is that Flash Player Plug-in for non-IE browsers does not send cookies in output requests and, therefore, session and authentication tickets are lost during the upload. To work around this problem, Image Uploader Flash wrappers for server platforms (ASP.NET and PHP) and JavaScript library provide special facilities. Let us consider how to use them.

## Preserving Cookies in ASP.NET

If you use Image Uploader Flash ASP.NET control to embed Image Uploader Flash in your application, session and authentication information will be automatically passed to the upload request. Otherwise, if the JavaScript library is used, you should add cookies to the upload request manually. To do it, use the addField(String, String) method of the metadata class.

### JavaScript

    $au.imageUploaderFlash({
        id: 'Uploader1',

        // ... other parameters

    });

    $au.imageUploaderFlash('Uploader1').metadata().addField('ASPNETSESSID', '<%=Page.Session.SessionID %>');
    $au.imageUploaderFlash('Uploader1').metadata().addField('ASPNETAUTHID', '<%=Request.Cookies[FormsAuthentication.FormsCookieName].Value %>');

    $au.imageUploaderFlash('Uploader1').writeHtml();

To restore passed cookies server-side you just need to add UploaderModule module to your web.config regardless of the way you used to embed Image Uploader Flash (ASP.NET control or JavaScript):

### XML

    <configuration>
       <system.web>
            <httpModules>
                <add name="UploaderModule" type="Aurigma.Uploader.UploaderModule"/>
            </httpModules>
       </system.web>
       <system.webServer>
            <modules>
                <add name="UploaderModule" type="Aurigma.Uploader.UploaderModule"/>
            </modules>
       </system.webServer>
    </configuration>

## Preserving Cookies in PHP

By analogy with Image Uploader Flash ASP.NET control, PHP library adds session cookie to the POST request when embedding Image Uploader Flash. If, however, you use Image Uploader Flash embedding scripts library you should perform this action manually:

### JavaScript

    $au.imageUploaderFlash({
        id: 'Uploader1',

        // ... other parameters

    });

    $au.imageUploaderFlash('Uploader1').metadata().addField('PHP_SESSIONID', '<?=$_COOKIE[session_name()]?>');

    $au.imageUploaderFlash('Uploader1').writeHtml();

On the server side the session can be restored using the restoreSession() function. This function returns true if the session was successfully restored; otherwise, false.

### PHP

    require_once '../ImageUploaderFlashPHP/Utils.class.php';
    Utils::restoreSession();

## See Also

### Reference

- metadata Class
- UploaderModule Class

### Manual

- Saving Uploaded Files in ASP.NET
- Saving Uploaded Files in PHP