单击每个链接或重新加载页面时,CodeIgniter检查会话变量是否已设置 [英] CodeIgniter-Checking session variable is already set or not when clicking each link or reloading page

查看:78
本文介绍了单击每个链接或重新加载页面时,CodeIgniter检查会话变量是否已设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个名为admin的控制器,如果设置了会话变量,则可以使用控制器中的所有函数,因此在单击页面中的每个链接或重新加载会话时,检查会话是否已设置的最佳方法是什么页...

I have a controller named admin,and all functions in the controller can be used if the session variable is set,so what are the best ways to check if the session is set ,when clicking each link in the page or reloading the pages...


例如:如果我在
浏览器中打开我的管理主页多个选项卡,第一个标签,bt之后在第二个标签
所有链接一个正常工作

for example: if i open my admin home page in multiple tabs in a browser and sign off from first tab, bt after that in the second tab all links a working properly

所以我想检查会话是否设置...

so i want to check if the session is set or not...

谢谢!

推荐答案

您想要检查会话变量是否设置,然后使用此。

If you want to check whether the session variable is set or not, then use this.

if($this->session->userdata('session_variable')) {

      // Do your code here
}

同时,如果你想检查会话变量是否设置了特定的值,那么你可以使用这个。

Meanwhile, if you want to check whether the session variable is set with a particular value, then you can use this.

if($this->session->userdata('session_variable') == "VALUE") {

      // Do your code here
}

这篇关于单击每个链接或重新加载页面时,CodeIgniter检查会话变量是否已设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆