You are here: Still fighting setcookie « PHP « IT news, forums, messages
Still fighting setcookie

Posted by John Hinton on 03/27/05 21:11

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация