Writing/Reading Custom Headers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Google Mike

    Writing/Reading Custom Headers

    Tell me if this can be done, and if I have a misconception here.

    I am writing an app that will be served up in an app farm, and
    therefore I need to move the session information to the client, not
    using server-side session features. The way I have typically done this
    in the ASP world was with cookies. Another way to handle this is with
    a keyed record in a database, but the cookie strategy reduces the
    number of times I need to hit a database, and allows me to scale the
    application better by not using a database table to store session
    information.

    However, I recently heard from a developer that, to get around the
    restrictions on cookies, their product switched to reading and writing
    custom headers. (The product, by the way, was Plumtree Corporate
    Portal.) Specifically the restrictions on cookies are from the
    goofball folks who install cookie security products or turn these off.
    (Gee, switching to the latest Mozilla always saved me the trouble of
    messing with cookie security holes.)

    So, I decided to start reading and writing custom headers. I want to,
    for instance, store a custom header, send a location header to
    redirect to another page, and then read that custom header back.
    (Imagine a login scenario where I verify login and then want to store
    a user's full name in a header, then redirect them to the main menu
    page.)

    I guess that would mean:

    $varlabel = 'FULLNAME';
    $varvalue = 'Google Mike';
    Header('TRACK_' . $varlabel . ': ' . $varvalue);
    Header('Locatio n: mainmenu.php'); //does a redirect
    Exit;

    But then on mainmenu.php, when I try to read all the headers back
    with...

    $headers = getallheaders() ;
    while (list($key, $val) = each($headers)) {
    echo "$key => $val<BR>\n";
    }

    ....I don't see any of the TRACK_* headers I was storing. What's the
    catch?
  • Google Mike

    #2
    Re: Writing/Reading Custom Headers

    Dang it. Looks like this article posted through Google Groups, after
    all. Sorry to have posted this twice.

    To be more brief, I was wondering why, when you use the header()
    function to write a custom header, then redirect to another page with
    header("Locatio n: test2.php"), the getallheaders() array doesn't
    return back the custom header that I wrote, but returns other browser
    headers.

    If you have an answer, I'd really like to know.

    Comment

    Working...