得到

2017-09-06 54 views
-1

我在一个模块和调试使用看门狗在Drupal 7得到

创建一个会话在模块文件我已经为

$_SESSION["celeType"] = $cele; 
$_SESSION["count"] = $count; 
watchdog('popup',print_r($_SESSION,TRUE)); 

建立在我的DBLOG我得到的值作为

会话数组值
Array ([celeType] => Birthday [count] => 1) 

在我的TPL我已经打印成

echo $cele=$_SESSION["celeType"]; 
    echo $count=$_SESSION["count"]; 

这不会打印任何值。我做错了什么。

+0

在使用'$ _SESSION'之前是否使用'session_start()'? – diavolic

+0

ya包含在模块文件 – user3386779

+0

转储价值的$ cele和$ count之前分配它,看看他们的内容是否为空 – Fky

回答

0
echo $cele=$_SESSION["celeType"]; 
echo $count=$_SESSION["count"]; 

它不应该是这个样子?:

echo $_SESSION['celeType']; 
echo $_SESSION['count']; 

不过,尝试做

print_r($_SESSION); 

要检查变量设置正确。

+0

我认为echo $ count = $ _ SESSION [“count”];是正确的,因为“赋值表达式的值是分配的值。”正如在php文档中所写的那样。看到http://php.net/manual/en/language.operators.assignment.php – lastYorsh

+0

还没有看到人们在echo语句中声明变量,这很奇怪,我不确定这是否正确,但仍然值得它尝试我所建议的,对吧? (: –

+0

是的,当然不是一个好习惯:) – lastYorsh