search
Homephp教程php手册php $_COOKIE简单应用实例

php $_COOKIE简单应用实例

Jun 13, 2016 am 10:03 AM
cookiephpinformationcontentsendExampleapplicationSimpleWeb page

COOKIE 是在网页内容发送之前。先发送出去的信息。也就是说。在这之前不能有任何的 HTML 代码和 echo 等,即使是一个空格也是不允许的。。

cookie 是在网页内容发送之前。先发送出去的信息。也就是说。在这之前不能有任何的 html 代码和 echo 等,即使是一个空格也是不允许的。。

在php教程中,要用 setcookie 函数来注册 cookie 变量,你上面的代码没有注册 cookie 变量。怎么可能送得过去呢。正确的写法如下:

*/
$status=0;                //定义状态
if(isset($_cookie['mytstcky'])&&($_cookie['mytstcky']=="chocchip")) $status=1; //如果已经设置变量
if(!isset($_get['cchk']))             //如果没有设置变量
{
  setcookie("mytstcky","chocchip");          //发送cookie信息
  header("location:$php_self?cchk=1");         //发送标头
  exit;                //结束php代码
}
?>

cookie check

cookie check status:
printf('%s
;',$status ? "00ff00" : "ff0000",$status ? "passed!" : "failed!");               //根据条件输出不同内容
?>

Statement
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 English version

SublimeText3 English version

Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.