两个CodeIgniter应用程序之间的会话共享 [英] Session sharing between two CodeIgniter Applications

查看:98
本文介绍了两个CodeIgniter应用程序之间的会话共享的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



第一个应用程式是:
localhost / aa / index.php
br />
第二个应用程序是:
localhost / aa / invoice / index.php



第二个应用程序在第一个应用程序文件夹中。在现实环境中,他们将在同一个域。我试图让一个单一的登录工作 - 所以,如果我有在aa应用程序中设置userdata,我应该能够在发票文件夹中验证它。



有没有办法分享会话。



由于文件夹将始终位于同一个域上,因此我可以使用ci库之外的会话(只有php)。



编辑:
当他们没有任何数据时,它们显示相同的会话ID。现在我在一个应用程序中添加一些变量,另一个不同步。



还有我的会话存储在数据库中(两个应用程序共享同一个数据库)。



请建议。



谢谢! :)

解决方案

Codeigniter由于某种原因卷起自己的会话实现,而不是本地PHP会话。



http://codeigniter.com/user_guide/libraries/sessions .html



您可以选择使用:


  1. Cookie存储(不理想,小存储大小,Cookie中的敏感数据)。

  2. 数据库会话(使用会话ID cookie保留)。


显然,您需要确保您的会话标识符配置正确,因此两者都必须正确配置。应用程序可以从同一会话数据读取。如果使用数据库实现,您需要确保两个应用程序都可以访问同一个数据库。



要增加复杂性,如果选择加密会话,由加密类在两个应用程序中也需要相同,因此任一个都能够解密共享会话数据。


I have 2 codeigniter installs running on the same server.

the first app is : localhost/aa/index.php

second app is : localhost/aa/invoice/index.php

The second app is in the first app folder. In the live environment, they will be on the same domain. I am trying to get a single sign-on to work -- so, if i have userdata set in the aa application I should be able to verify it in the invoice folder also.

Is there a way to share the sessions.

As the folders will always be on the same domain, I am open to working with sessions outside the ci library(only php) also.

Edit : They show the same session id when they don't have any data. The moment I add some variables on one application, the other goes out of sync.

Also I have sessions being stored in the database(both applications share the same database.)

Please suggest.

Thanks! : )

解决方案

Codeigniter for some reason rolls its own session implementation rather than native PHP sessions.

http://codeigniter.com/user_guide/libraries/sessions.html

You get a choice of using:

  1. cookie storage (not ideal, small storage size, sensitive data in a cookie?).
  2. database sessions (persisted using session id cookie).
  3. Override and roll your own (to use native php sessions!)

Obviously you need to make sure your session identifier is configured correctly so both apps can read from the same session data. If using the database implementation, you need to make sure both apps can access the same DB.

To add to the complexity, if you choose to encrypt sessions, the salt used by the encryption class will also need to be the same in both apps, so either one is able to decrypt the shared session data.

这篇关于两个CodeIgniter应用程序之间的会话共享的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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