您如何在Wordpress中使用会话变量? [英] How do you use session variables in wordpress?
本文介绍了您如何在Wordpress中使用会话变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下插件: http://wordpress.org/support/plugin /wp-session-manager
我无法弄清楚如何在WordPress中使用会话变量.根据我的阅读理解,应该使用它:
I cannot work out how to use the session variables in WordPress. From what I understand by reading, this is how it should be used:
我在第一页(第1页)上有以下内容:
I have the following on page one (page 1):
global $wp_session;
$wp_session['loggedIn'] = 15;
echo $wp_session['loggedIn'];
在第一页上,会话变量有效,但是在第二页上,会话变量无效. 谁能告诉我我要去哪里错了?
On the first page, the session variable is working but on the second page, the session variable is not working. Can anyone suggest me where I am going wrong?
谢谢.
推荐答案
替换:
global $wp_session;
使用:
$wp_session = WP_Session::get_instance();
在尝试回显第2页上的变量之前,请确保添加$wp_session = WP_Session::get_instance();
.
Make sure you add $wp_session = WP_Session::get_instance();
before you try to echo the variable on page 2.
这篇关于您如何在Wordpress中使用会话变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文