Page 3 of 3 FirstFirst 123
Results 21 to 26 of 26

Thread: redirect using header()

  1. #21
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    You're probably right. The header() call will not function after the output from the error report was sent. Prepend the _set_cookie() call with the @ operator.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  2. #22
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    I found the problem. The issue of the session variables has changed between php 3.X and 4.4 with further changes into 6.0. Just can't use things the same way because:
    Code:
     session_register() accepts a variable number of arguments, any of which can be either a string holding the name of a variable or an array consisting of variable names or other arrays. For each name, session_register() registers the global variable with that name in the current session.
    
    Caution
    
    If you want your script to work regardless of register_globals, you need to instead use the $_SESSION array as $_SESSION entries are automatically registered. If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.
    
        register_globals: important note: Since PHP 4.2.0, the default value for the PHP directive register_globals is off, and it is completely removed as of PHP 6.0.0. The PHP community encourages all to not rely on this directive but instead use other means, such as the superglobals.
    So, it looks like I need to change from
    Code:
    'session_register("where"); $where = "http://earth.engr.ccny.cuny.edu/noaa/wc/Lidar/chainedmenu2.php";'
    to
    Code:
    $_SESSION['where'] = "http://earth.engr.ccny.cuny.edu/noaa/wc/Lidar/chainedmenu2.php"
    Right? I'll try that out.

  3. #23
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    's right. I would have thought, however, that session_register() would simply add the variable to $_SESSION, where register_globals was off.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  4. #24
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    It's very plain, now, that the variable $_SESSION['where'] works only within a page, and is NOT passed correctly.

    I define it at the beginning of chainedmenu2.php and it is not there when it goes to the login screen.

    If I define it in auth.inc.php and use it in the header statement, the redirect back to chainedmenu2.php says that it is there, but ONLY because it is in the first lines of php code. I know this to be true because I made a second copy/version of chainedmenu2 (chainedmenu3.php) without the $_SESSION declaration and the different redirect or 'which' def, and the value was NOT passed. So, something is really wrong, and I just don't know what it is. Help please (sigh)?

  5. #25
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Sure you called session_start(), and are you sure that no HTML was sent first? Not even a linebreak before the <?php?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #26
    Join Date
    Feb 2006
    Posts
    236
    Thanks
    8
    Thanked 3 Times in 3 Posts

    Default

    Yes, I did that. The key is that session_start() ALSO must be the first line of the included files! I just fixed that and everything is OK now. Thanks for your help, Twey.

Bookmarks

Posting Permissions

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