CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Hybrid View

  1. #1
    Join Date
    Mar 2009
    Posts
    2

    PHP: $_SERVER['REQUEST_URI'] string corrupted when saving to $_SESSION (IE only)

    Prepare to be amazed.

    Server: Linux (Debian), Apache, MySQL, PHP 5.2
    Apache/2.2.3 (Debian) PHP/5.2.0-8+etch13 mod_ssl/2.2.3 OpenSSL/0.9.8c

    Problem Occurs in Environment:
    ONLY Internet Explorer v6, v7, when page is in SSL mode (using a valid certificate, self signed certificates don't cause the problem)

    Problem:
    If you save $_SERVER['REQUEST_URI'] to a $_SESSION["last_page"] and then on the next page print out that value, it will look something like this:

    Original Value Saved to Session: /admin/site/admin/menu/
    Value Retrieved from Session: /admin/site/admin/://0

    If I save a manually entered string that matches that exact path, it prints out fine. But the value provided by the $_SERVER variable, causes corruption when saved to a session. And the corruption is bizzare. I don't understand what that colon is for? I've done a ton of tests, and it gets even weirder.

    I saved the whole $_SERVER array to a session and then printed out the results. All the values of the array were fine, except for some strange reason the string paths in $_SERVER['REQUEST_URI'] and $_SERVER['REDIRECT_URL'] variables are transformed and converted to include this "/://0" at the end.

    I tried urlencode(utf8_encode(strval(trim($_SERVER['REQUEST_URI'])))), etc. on the Variable but it still gets manipulated.

    I tried str_split($_SERVER['REQUEST_URI'], 1) so that each letter was it's own value in an array, and it STILL converted it AFTER it was retrieved from the session. Example:

    ORIGINAL ARRAY:
    Array
    (
    [0] => /
    [1] => a
    [2] => d
    [3] => m
    [4] => i
    [5] => n
    [6] => /
    [7] => s
    [8] => i
    [9] => t
    [10] => e
    [11] => /
    [12] => a
    [13] => d
    [14] => m
    [15] => i
    [16] => n
    [17] => /
    [18] => b
    [19] => a
    [20] => s
    [21] => i
    [22] => c
    [23] => _
    [24] => p
    [25] => a
    [26] => g
    [27] => e
    [28] => s
    )

    RETREIVED FROM SESSION
    Array
    (
    [0] => /
    [1] => a
    [2] => d
    [3] => m
    [4] => i
    [5] => n
    [6] => /
    [7] => s
    [8] => i
    [9] => t
    [10] => e
    [11] => /
    [12] => a
    [13] => d
    [14] => m
    [15] => i
    [16] => n
    [17] => /
    [18] => :
    [19] => /
    [20] => /
    [21] => 0
    )

    It's shorter, missing part of the string, and has that crazy "/://0" at the end.

    What in the world is going on? I've been picking at this problem for a year, and have found no solutions and am getting desperate.

    Any clues?

  2. #2
    Join Date
    Mar 2009
    Posts
    2

    Re: Occurs in SSL mode with apache rewriting

    My CMS using apache rewriting to take any URL path and load an /index.php file. The path remains the same in the browser, and the $_SERVER["REQUEST_URI"] reports the requested URI. So it all looks and works correctly. But I uploaded an actual file with this test script and viewed in SSL mode and the issue described above does not happen. So it appears to only occur when the path has been rewritten and it's not accessing an actual file.

Tags for this Thread

Posting Permissions

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





Click Here to Expand Forum to Full Width

Featured