0

uploader interfering with cookies?

I am using the Browser Plus zipper with my own uploader because of the need for secure file transfers(FTP with SSL). I am calling the upload.php the same way as in the zipper/uploader example. I have a cookie set by javascript on the client that contains information I need to name the zip files as I upload them. For some reason The cookie is not visible from the upload.php. Is Browser Plus somehow preventing me from seeing the cookie? The cookie is visible from the browser by typing java script:alert(document.cookie); in the browser , but print_r($_COOKIE); from the PHP script yields array().

by
3 Replies
  • QUOTE (tim_hoehn @ Aug 10 2009, 06:42 PM) <{POST_SNAPBACK}>
    I am using the Browser Plus zipper with my own uploader because of the need for secure file transfers(FTP with SSL). I am calling the upload.php the same way as in the zipper/uploader example. I have a cookie set by javascript on the client that contains information I need to name the zip files as I upload them. For some reason The cookie is not visible from the upload.php. Is Browser Plus somehow preventing me from seeing the cookie? The cookie is visible from the browser by typing java script:alert(document.cookie); in the browser , but print_r($_COOKIE); from the PHP script yields array().


    How are you setting the cookie in the call to BrowserPlus? Can you post a little bit of code?

    Regards,

    Steve Spencer
    0
  • Basically I just have a static HTML file with my BrowserPlus javascript at the end of it. I have tried various methods but currently I call a PHP script that sets the cookie. The upload works, but just not the cookie part.

    The call from the html to the cookie setting php:

    <script language="javascript" src="settimestampcookie.php"> </script>

    The cookie setting script:

    <?php
    //use time stamp for unique identification
    $timestamp = time();
    if($timestamp != null)
    {
    //Create cookie
    setcookie('csocookie', $timestamp);
    }
    ?>



    The function that calls the PHP uploader (almost identical to the zipper/uploader example:

    function uploadInputFiles(e)
    {
    elFile.innerHTML ="Uploading...";
    elZip.innerHTML = "";
    if (ZippedFiles != null)
    {
    BrowserPlus.Uploader.upload(
    {
    url: "inputupload.php",
    files: {"file": ZippedFiles}
    },
    function(res)
    {
    if (res.success)
    {
    elFile.innerHTML ="Uploaded of Folder 1 Successful! Please continue to step 2.";
    elZip.innerHTML = res.value.body;
    }
    else
    {
    elZip.innerHTML = "ERROR: " + res.error;
    }
    });
    }
    return false;
    }


    Before the user pushes the upload button I can see the cookie from the browser. But when the following upload script runs, it sees no cookies.

    <?php

    //Get the cookie
    if (isset($_COOKIE['csocookie']))
    {
    $timestamp = $_COOKIE['csocookie'];
    }
    else
    {
    $timestamp = $_POST['timestamp'];
    }

    echo "timestamp = " . $timestamp;


    uploads the file, etc....
    ?>
    0
  • if I read the cookie just from a php file called by a web page It can see it fine.

    If I call the same php (same code in upload.php) from the BrowserPlus javascript, it cannot see the cookie.

    BrowserPlus.Uploader.upload(
    {
    url: "upload.php",
    files: {"file": ZippedFiles}

    etc...
    },
    0
This forum is locked.

Recent Posts

in Support & General Questions