Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Header/Session

  1. #1
    Regular Coder
    Join Date
    Mar 2006
    Location
    Nigeria
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Header/Session

    Ive been having problems with when using header() and session() on the same page. I am actually trying to create a download page that checks if a certain session is registered before bringing up the save as dialogue box via header. The script looks something like this -
    PHP Code:
    <?php
    session_save_path
    ('../../../my_sessns');
    session_start();
    if(
    $_SESSION['cur_usr']){
    //get $_get variable and declare some variables
            
    header("Pragma: no-cache");
            
    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
            
    header("Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0");
            
    header("Content-type: $mime");
            
    header("Content-Length: $filesize");
            
    header("Accept-Ranges: bytes");
            
    header("Content-Disposition: attachment; filename=\"$file\"");
            
    header("Content-Transfer-Encoding: binary");
            
    set_time_limit(0);
            
    readfile("../../../files/$dir/$file");
            exit;
    }
    else{
        include_once 
    '../includes/register.php';
    }
    ?>
    The script seem to work well on firefox and opera (9) but doesnt on IE7. Any ideas what could be wrong?

  • #2
    Senior Coder CFMaBiSmAd's Avatar
    Join Date
    Oct 2006
    Location
    Denver, Colorado USA
    Posts
    3,131
    Thanks
    2
    Thanked 328 Times in 320 Posts
    Define: "doesnt on IE7" Telling us that it does not work does not narrow it down. We can guess this much because you are asking a question on a help forum.

    What does it do? What symptoms are there?
    Last edited by CFMaBiSmAd; 03-01-2007 at 08:16 PM. Reason: fixed word
    If you are learning PHP, developing PHP code, or debugging PHP code, do yourself a favor and check your web server log for errors and/or turn on full PHP error reporting in php.ini or in a .htaccess file to get PHP to help you.

  • #3
    Super Moderator JohnDubya's Avatar
    Join Date
    Nov 2006
    Location
    Missouri
    Posts
    634
    Thanks
    12
    Thanked 18 Times in 18 Posts
    Is there an error, or is it just not working?

  • #4
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    There's quite some pickyness with browsers and sending files like this.

    Just look at the notes for header(). I've found all my solutions for this here.

    http://us2.php.net/manual/en/function.header.php

  • #5
    Regular Coder
    Join Date
    Mar 2006
    Location
    Nigeria
    Posts
    192
    Thanks
    0
    Thanked 0 Times in 0 Posts
    No errors displayed. Though it puts up the save as dialogue box, it simply downloads the script page


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •