sending session cookie before redirect

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gary Petersen

    #16
    Re: sending session cookie before redirect

    A horsie named 11abacus demonstrated surprising intelligence and its
    ability to use morse code on Tue, 09 Sep 2003 11:05:14 -0500 when it
    tapped <1a2a8cd7.03090 90805.3aa475c5@ posting.google. com> with its hoof:
    [color=blue]
    > "Set-Cookie:" and "Location:" HTTP headers don't mix well with most web
    > browsers [...][/color]

    The following script, which uses both setcookie() and
    the location header, works with these web browsers:
    Lynx, Firebird, Mozilla, Galeon, Konqueror, wget.

    wget doesn't seem to like cookies that have square
    brackets [] in them, but it did accept and use
    the 'captain' cookie.

    <?php
    // PHP 4.0.5
    error_reporting (E_ALL);

    $g = & $HTTP_GET_VARS;
    $c = & $HTTP_COOKIE_VA RS;
    $s = & $HTTP_SERVER_VA RS;
    $ttl = time() + 86400;

    header('Cache-control: no-cache');
    header('Pragma: no-cache');

    if (!isset($g['show'])):
    setcookie('user[cindy]', '8', $ttl, '/');
    setcookie('user[mark]', '4', $ttl, '/');
    setcookie('user[jarmain]', 41, $ttl, '/');
    setcookie('capt ain', 'mark', $ttl, '/');
    header("Locatio n: http://$s[HTTP_HOST]$s[PHP_SELF]?show=1");
    exit();
    else:
    ?>
    <title> A Cookie Test </title>
    <p> This page sets and displays some cookies.
    </p>
    <?php
    echo "<pre>\n";
    print_r($c);
    echo "</pre>\n";
    endif;
    ?>

    I don't have access to MSIE; perhaps someone can test
    with that one.

    Comment

    • Jochen Daum

      #17
      Re: sending session cookie before redirect

      Hi !

      On Wed, 10 Sep 2003 05:19:58 GMT, Gary Petersen
      <garyp1492@remo ve.meearthlink. invalid> wrote:
      [color=blue]
      >A horsie named 11abacus demonstrated surprising intelligence and its
      >ability to use morse code on Tue, 09 Sep 2003 11:05:14 -0500 when it
      >tapped <1a2a8cd7.03090 90805.3aa475c5@ posting.google. com> with its hoof:
      >[color=green]
      >> "Set-Cookie:" and "Location:" HTTP headers don't mix well with most web
      >> browsers [...][/color]
      >
      >The following script, which uses both setcookie() and
      >the location header, works with these web browsers:
      >Lynx, Firebird, Mozilla, Galeon, Konqueror, wget.
      >
      >wget doesn't seem to like cookies that have square
      >brackets [] in them, but it did accept and use
      >the 'captain' cookie.
      >[/color]

      So I just have to find out how to set the PHPSESSID cookie, ey?
      Shouldn't be to hard.

      Thanks for the help.

      Jochen

      [color=blue]
      ><?php
      >// PHP 4.0.5
      >error_reportin g(E_ALL);
      >
      >$g = & $HTTP_GET_VARS;
      >$c = & $HTTP_COOKIE_VA RS;
      >$s = & $HTTP_SERVER_VA RS;
      >$ttl = time() + 86400;
      >
      >header('Cach e-control: no-cache');
      >header('Pragma : no-cache');
      >
      >if (!isset($g['show'])):
      > setcookie('user[cindy]', '8', $ttl, '/');
      > setcookie('user[mark]', '4', $ttl, '/');
      > setcookie('user[jarmain]', 41, $ttl, '/');
      > setcookie('capt ain', 'mark', $ttl, '/');
      > header("Locatio n: http://$s[HTTP_HOST]$s[PHP_SELF]?show=1");
      > exit();
      >else:
      >?>
      > <title> A Cookie Test </title>
      > <p> This page sets and displays some cookies.
      > </p>
      ><?php
      > echo "<pre>\n";
      > print_r($c);
      > echo "</pre>\n";
      >endif;
      >?>
      >
      >I don't have access to MSIE; perhaps someone can test
      >with that one.[/color]

      --
      Jochen Daum - CANS Ltd.
      PHP DB Edit Toolkit -- PHP scripts for building
      database editing interfaces.
      http://sourceforge.net/projects/phpdbedittk/

      Comment

      Working...