asked on
<?php
setcookie("ticker",'testing');
echo $_COOKIE['ticker']."=====<br/>";
?>
ASKER
<?php
setcookie("ticker",'testing');
echo $_COOKIE['ticker']."=====<br/>";
header("location: http://mysite.com/cookie.php");
?>
ASKER
<?php
setcookie("ticker",'testing');
if (isset($_COOKIE['ticker'])) {
/* ticker cookie is set so do other php code here */
}
else header("location:main.php"]
?>
<html>
<body>
</body>
......code html here
</html>
ASKER
<?php
// SET A COOKIE, ...
// BUT FOR WHAT SUBDOMAINS?
// AND WHAT PATH?
// HOW LONG SHOULD THE COOKIE LIVE?
// SHOULD IT BE VISIBLE TO JAVASCRIPT OR NOT?
setcookie("ticker",'testing');
// IF THIS COOKIE ALREADY EXISTED BEFORE THIS HTTP REQUEST
if (isset($_COOKIE['ticker'])) {
/* ticker cookie is set so do other php code here */
}
// IF THIS COOKIE DID NOT ALREADY EXIST BEFORE THIS HTTP REQUEST
// MISSING STATEMENT TERMINATOR CAUSES A PARSE ERROR;
else header("location:main.php"]
// THE SCRIPT WILL NEVER GET TO THIS INSTRUCTION BECAUSE IF/ELSE WILL STOP IT
?>
<html>
<body>
</body>
......code html here
</html>
ASKER
<?php
$path=str_ireplace($_SERVER['DOCUMENT_ROOT'], '', dirname($_SERVER['SCRIPT_FILENAME']));
setcookie("ticker","testing", time()+3600*8, $path."/", $_SERVER["HTTP_HOST"], 0,1);
if (isset($_COOKIE['ticker'])) {
header("location:second.php");
}
else {
header("location:first.php")
;}
?>
PHP is a widely-used server-side scripting language especially suited for web development, powering tens of millions of sites from Facebook to personal WordPress blogs. PHP is often paired with the MySQL relational database, but includes support for most other mainstream databases. By utilizing different Server APIs, PHP can work on many different web servers as a server-side scripting language.
TRUSTED BY
ASKER
the result of cookie at second time of http request, Right ?