Home > Backend Development > PHP Tutorial > 一个简单的cookie求教解决方案

一个简单的cookie求教解决方案

WBOY
Release: 2016-06-13 13:36:13
Original
892 people have browsed it

一个简单的cookie求教

PHP code
<!--

Code highlighting produced by Actipro CodeHighlighter (freeware)
http://www.CodeHighlighter.com/

-->
<?php $name=$_GET["name"];
$value=$_GET["value"];
setcookie($name,$value);
?>
<?php echo $_COOKIE["name"];
?>
<?php for($i=0;$i<10;$i++)
{
?>
<a href="test.php?name=name&value=<?=%24i?>">=$i?></a>
<?php }
?>

Copy after login



请教 如何在第一次点击的时候 就获取正确的cookie的值
这个程序要点两次才可以获得正确的 第一次点击 是记录上一次点击的值
求教求教

------解决方案--------------------
$name=$_GET["name"];
$value=$_GET["value"];
setcookie($name,$value);

$_COOKIE[$name] = $value;
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template