Codeigniter / PHP中的多个会话 [英] Multiple Sessions in Codeigniter/PHP

查看:93
本文介绍了Codeigniter / PHP中的多个会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在codeigniter中开发了一个电子商务网站,其中有以下会话:

I am developing a e-commerce website in codeigniter having sessions for following:


  1. 管理员登录

  2. 购物车

  3. 用户登录

现在我无法找出机制使用不同的数据集来管理这三个会话。

Now i am unable to figure out a mechanism for managing these three sessions with different sets of data.

我知道可以通过core_name中的session_name()来实现。但是用codeigniter我有点困惑。
Googled it了很多,但找不到一个正确的答案。

I know it can be achieved with session_name() in core php. But with codeigniter i am a bit confused. Googled it a lot but couldn't found a proper answer.

我想要清楚了解codeigniter中的多个会话,以便它不创建任何混乱在未来。任何指向教程的链接都是很好的。

I want a clear understanding of multiple sessions in codeigniter so that it doesn't create any confusion in future. Any link to tutorial would be great.

推荐答案

Codeigniter的会话与本地PHP会话完全不同,数据库。你可以使用codeigniter的会话和本地PHP会话,他们会一起工作,因为PHP会看到不同的变量。
如果要检查是否存在codeigniter会话值,请使用

Codeigniter's session is completely different from Native PHP Session and it's very secure especially when stored in a database. You can work with codeigniter's sessions and Native PHP Session they would work fine together because PHP would see the as different variables. If you want to check for the existence of a codeigniter session value use

if(isset($this->session->userdata['course_id']))
{
    $this->data['course_id'] = $this->session->userdata('course_id');
} 

虽然Native PHP看起来像

While Native PHP would look like

if(isset($_SESSION['course_id']))
{
    $this->data['course_id'] = $_SESSION['course_id'];
} 

这篇关于Codeigniter / PHP中的多个会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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