background image

Echo "本页得到的_COOKIE 变量有:";

伊图教程网[www.etoow.com]
http://www.etoow.com/html/2007-02/1170384144.html
Print_R($_COOKIE);

Echo "本页得到的_SESSION 变量有:";
Print_R($_SESSION);
Echo "</pre>";
?>

  然后在 php.ini 中设置:include_path = "c:/php",并将 debug.php 放
在此文件夹,以后就可以在每个网页里包含此文件,查看得到的变量名和值.

  3:如何使用 session

  凡是与 session 有关的,之前必须调用函数 session_start();

  为 session 付值很简单,如:

<?php
Session_start();
$Name = "这是一个 Session 例子";
Session_Register("Name");//

,

Session_Register("$Name");
Echo $_SESSION["Name"];
//之后$_SESSION["Name"]为"这是一个 Session 例子"
?>

  在 php4.2 之后,可以为 session 直接付值:

<?PHP
Session_Start();
$_SESSION["name"]="value";
?>

  取消 session 可以这样:

<?php
session_start();
session_unset();
session_destroy();
?>