1

我将更新代码更改为 PHP 5.3 。为了解决这个问题,我SESSION_REGISTER()从我的代码中删除并更改SESSION_UNREGISTER()unset();这对我有用。这是真的吗?这是一个确定的方法吗?PHP 手册(SESSION_REGISTERSESSION_UNREGISTER

旧代码(SESSION_REGISTER):

SESSION_REGISTER("UID");$_SESSION[UID]=$res->fields[uid];
SESSION_REGISTER("EMAIL");$_SESSION[EMAIL]=$res->fields[email];
SESSION_REGISTER("USERNAME");$_SESSION[USERNAME]=$res->fields[username];
SESSION_REGISTER("IS_ACTIVE");$_SESSION[IS_ACTIVE]=$res->fields[is_active];

$_SESSION[UID]=$res->fields[uid];
$_SESSION[EMAIL]=$res->fields[email];
$_SESSION[USERNAME]=$res->fields[username];
$_SESSION[IS_ACTIVE]=$res->fields[is_active];

旧代码(SESSION_UNREGISTER):

$_SESSION["UID"]    = ''; session_unregister("UID");
$_SESSION["EMAIL"]  = ''; session_unregister("EMAIL");
$_SESSION["USERNAME"]   = ''; session_unregister("USERNAME");

unset($_SESSION["UID"]);
unset($_SESSION["EMAIL"]);
unset($_SESSION["USERNAME"]);
session_destroy();

谢谢。

4

1 回答 1

0

这可以正常工作,只需确保引用了数组键:

$_SESSION['UID']=$res->fields['uid'];
$_SESSION['EMAIL']=$res->fields['email'];
$_SESSION['USERNAME']=$res->fields['username'];
$_SESSION['IS_ACTIVE']=$res->fields['is_active'];
于 2012-07-26T10:08:06.740 回答