Home  >  Article  >  Backend Development  >  代码贴出~希望能找出小弟我错在什么地方.多谢

代码贴出~希望能找出小弟我错在什么地方.多谢

WBOY
WBOYOriginal
2016-06-13 13:13:21970browse

代码贴出~~~~~~~~~希望能找出我错在什么地方..谢谢
基础贴

index.php

PHP code
<!--

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

-->
 <?php session_start();
session_unset();
session_destroy();
session_register("pass");
$password=111;
$HTTP_SESSION_VARS["pass"]=$password;
echo $HTTP_SESSION_VARS["pass"];?> 
<a href="session.php">
请点击第二页面</a> 



session.php
PHP code
<!--

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

-->
<?php session_start();
$i=$_SESSION['pass'];
if(isset($i))
{
    echo "成功";
    echo $i;
    }
    else
    {
        echo "失败";
        
        }

?>



------解决方案--------------------
去掉这三行:
session_unset(); //这是关闭 session
session_destroy(); //这也是关闭 session
session_register("pass");//这个函数已经失效了
对session赋值用
$_SESSION['pass'] = $password;
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