Still fighting setcookie

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



OK, I created this most simplistic script..

---- Begin Script-------------------------------------------

<?php
if(isset($value))
{
 setcookie("mycookie",$value);
}

define (Login, 0);
define (DataReturn, 1);

function login() {
echo "<form ACTION=\"$_SERVER[PHP_SELF]?action=1\" METHOD=\"post\" ENCTYPE=\"multipart/form-data\">";
echo "Type value: <input name=\"value\" type=\"text\">";
echo "<input name=\"submit\" type=\"submit\">";
echo "</form>";
}


function datareturn(){
print_r($_COOKIE);
echo " is the \$_COOKIE data";
}

if (empty ($action))
      $action = 0;
switch ($action) {
case Login:
  login();
  break;
case DataReturn:
      datareturn();
      break;
default:
      die ("Unknown action code ($action)");
}
?>

----End Script------------------------

I would expect the return on action=1 to report the set cookie, but instead, it has no data. If I then reload the browser, the cookie appears. How can I get the cookie to set without this reload? What am I missing?

Thanks a bunch...
John Hinton

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux