在函数里注册SESSION变量
$_SESSION['NAME'] = $VAR

解决方案 »

  1.   

    若是全局变量,自然是能访问的啦若是还有问题,则使用global关键字,在每一个调用它的地方使用就绝对ok
      

  2.   

    $Session["tt"]="fff";
    function getxx(&$sessionvar){
        $sessionvar="ggg";
    }
    $f=getxx($Session["tt"]);
      

  3.   


    $HTTP_SESSION_VAR["USER"]
    在类,函数中。
      

  4.   

    用GLOBLE来声明一下可能行的。
      

  5.   

    Function里是这样的
    <?php
    function Sadd(){
    $temp1="qqq";
    $temp2="www";
    $temp3="eee";
    session_register("session_temp1");
    session_register("session_temp2");
    session_register("session_temp3");
    $session_temp1=$temp1;
    $session_temp2=$temp2;
    $session_temp3=$temp3;}
    ?>
    外面访问是这样的
    echo $session_temp1;
      

  6.   

    Function里是这样的
    <?php
    function Sadd(){
    $temp1="qqq";
    $temp2="www";
    $temp3="eee";
    session_register("session_temp1");
    session_register("session_temp2");
    session_register("session_temp3");
    $session_temp1=$temp1;
    $session_temp2=$temp2;
    $session_temp3=$temp3;
    //---------------------------------------  加上这个吧
    $GLOBALS['session_temp1'] = $temp1;
    $GLOBALS['session_temp2'] = $temp2;
    $GLOBALS['session_temp3'] = $temp3;
    //---------------------------------------  加上这个吧
    }
    ?>
    外面访问是这样的
    echo $session_temp1;
    这样应该没有问题了
      

  7.   

    <?php
    function Sadd(){
    $temp1="qqq";
    $temp2="www";
    $temp3="eee";
    session_register("session_temp1");
    session_register("session_temp2");
    session_register("session_temp3");////应该这样
    $session_temp1=$temp1;//$_SESSION["session_temp1"]=$temp1;
    $session_temp2=$temp2;//$_SESSION["session_temp2"]=$temp2;
    $session_temp3=$temp3;//$_SESSION["session_temp3"]=$temp3;}
    ?>
    ps:$_SESSION本身就是superglobal,在任何地方都不需要global
      

  8.   

    实践证明,
    //---------------------------------------  加上这个吧
    $GLOBALS['session_temp1'] = $temp1;
    $GLOBALS['session_temp2'] = $temp2;
    $GLOBALS['session_temp3'] = $temp3;
    //---------------------------------------  加上这个吧
    是有必要的。
      

  9.   

    唔~~~
    就是一个简单的东东,从PHP4.2开始就有了$_SESSION[] 超级全局数组,
    什么$GLOBALS都不用了,程序如下:<?php
    session_start();
    function Sadd()
    {
    $temp1="qqq";
    $_SESSION["session_temp1"]=$temp1;}
    Sadd();
    echo $_SESSION["session_temp1"];
    ?>