Reading and Writing Headers

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

    Reading and Writing Headers

    Gosh. I posted this earlier on Google Groups, but it didn't appear.
    Perhaps there was a problem at Google. Forgive me for posting it
    again. This time, I'll be more brief.

    Instead of using cookies, I want to play with HTTP headers in general
    because I heard you can use these to circumvent cookie
    security/cleaner type apps (which I consider silly, btw). I want to
    write custom headers like:

    TRACK_fullname: Google Mike

    I want to load a PHP page, write a custom header like that, then write
    a Location header to redirect to another page, as in:

    header('TRACK_f ullname: Google Mike');
    header('Locatio n: test2.php');
    exit;

    On test2.php, I want to read this back. I cycle through the array
    returned by getallheaders() , but I don't see "TRACK_fullname " in
    there.

    What's the catch?
  • Alan Little

    #2
    Re: Reading and Writing Headers

    Carved in mystic runes upon the very living rock, the last words of
    Google Mike of comp.lang.php make plain:
    [color=blue]
    > I want to load a PHP page, write a custom header like that, then write
    > a Location header to redirect to another page, as in:
    >
    > header('TRACK_f ullname: Google Mike');
    > header('Locatio n: test2.php');
    > exit;
    >
    > On test2.php, I want to read this back. I cycle through the array
    > returned by getallheaders() , but I don't see "TRACK_fullname " in
    > there.[/color]

    The header() function sends response headers to the browser. The browser
    sees the Location: header and generates a new request for that resource.
    It has no idea what your custom header means, and has no reason to pass
    it on in the request.

    --
    Alan Little
    Phorm PHP Form Processor

    Comment

    • BKDotCom

      #3
      Re: Reading and Writing Headers

      googlemike@hotp op.com (Google Mike) wrote in message news:<25d8d6a8. 0310091748.2257 2f71@posting.go ogle.com>...
      [color=blue]
      > I want to load a PHP page, write a custom header like that, then write
      > a Location header to redirect to another page, as in:
      >
      > header('TRACK_f ullname: Google Mike');
      > header('Locatio n: test2.php');
      > exit;
      >
      > On test2.php, I want to read this back. I cycle through the array
      > returned by getallheaders() , but I don't see "TRACK_fullname " in
      > there.
      >
      > What's the catch?[/color]

      Unless your user has some special browser that recognises
      'TRACK_fullname ', it's just going to be ignored. The browser isn't
      a header messenger.

      Comment

      • sk

        #4
        Re: Reading and Writing Headers

        The only headers of this kind that you can send out like this and pick
        up in the browser are, yes, cookies.

        Of course, if what you want to do is pass something along to track in
        your redirect and not worry about cookies, you can either use sessions
        (for a redirect within the same site) or just set your own GET parameter
        in the redirect URL, as in:

        header('Locatio n: test2.php?TRACK _fullname=Googl e%20Mike');

        Google Mike wrote:[color=blue]
        > Gosh. I posted this earlier on Google Groups, but it didn't appear.
        > Perhaps there was a problem at Google. Forgive me for posting it
        > again. This time, I'll be more brief.
        >
        > Instead of using cookies, I want to play with HTTP headers in general
        > because I heard you can use these to circumvent cookie
        > security/cleaner type apps (which I consider silly, btw). I want to
        > write custom headers like:
        >
        > TRACK_fullname: Google Mike
        >
        > I want to load a PHP page, write a custom header like that, then write
        > a Location header to redirect to another page, as in:
        >
        > header('TRACK_f ullname: Google Mike');
        > header('Locatio n: test2.php');
        > exit;
        >
        > On test2.php, I want to read this back. I cycle through the array
        > returned by getallheaders() , but I don't see "TRACK_fullname " in
        > there.
        >
        > What's the catch?[/color]

        Comment

        Working...