English 中文(简体)
两个 CoDIgniter 应用程序之间的会话共享
原标题:Session sharing between two CodeIgniter Applications

我在同一服务器上有两个编码员安装设备。

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

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

第二个应用程序在第一个应用程序文件夹中。 在实时环境中, 它们将在同一域名上。 我正试图获得一个单一的签名来工作, 所以, 如果应用程序中有用户数据, 我也可以在发票文件夹中验证它 。

是否有办法分享会议内容。

由于文件夹总是在同一域名上,我愿意与ci 库(只有php)以外的会议一起工作。

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.

我还把会议存入数据库(两个应用程序共用同一数据库)。

请建议。

谢谢!

最佳回答

出于某种原因,协调者自行安排会议执行情况,而不是本地的PHP会议。

http://codigniter.com/user_guide/libraris/sessions.html

你可以选择使用:

  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!)

显然,您需要确保会话标识符的配置正确, 这样两个应用程序都可以从同一个会话数据读取。 如果使用数据库执行, 您需要确保两个应用程序都能访问同一个 DB 。

要增加复杂性, 如果您选择加密会话, 加密类所使用的盐在两个应用程序中也需要相同, 所以任何一方都可以解密共享会话数据 。

问题回答
$config[ encryption_key ] =  epitome ;

encryption_key 配置名称与两个应用程序文件夹相同 。

更改代码编辑中的 encryption_key 路径为 application/config/config.php 行号 228。

$config[ sess_cookie_name ] =  myvalue ;

在 config.php 文件中, 您可以在两个 CI Apps 上设置相同的值, 文件会话驱动程序

CI_Session Object

( [userdata] => Array ( [__ci_last_regenerate] => 1490351129 [Level] => 1 [User] => 103 [Fullname] => Joe Doe )

[_driver:protected] => files
[_config:protected] => Array
    (
        [cookie_lifetime] => 600
        [cookie_name] => MyHiddenValue
        [cookie_path] => /
        [cookie_domain] => 
        [cookie_secure] => 
        [expiration] => 600
        [match_ip] => 
        [save_path] => /tmp
    )

)

If I may .... I have noted that those design problems which are not practical and goes against the normal convention shall provided a basis for long and deep rooted problems.... You should ask your self it is really necessary / advisable to share session data between 2 different version of a framework when we know they are 2 different version for the reason that they do things differently... I can only say that no matter what you do.. this design flaw shall make your architecture fragile and sooner or later you will have to dump it.

普尔兹告诉我,如果以后你发现 否则...

如果您使用相同的加密密钥在同一服务器上安装代码, 默认情况下, 两种安装都会共享会话 。 事实上, 当我为另一个客户端复制一个编码员安装时, 我发现了这个代码, 但是在同一个服务器上。 我认为这是一个错误, 我担心 。

如果将代码移动到同一个服务器,两个会话将默认地开始共享。





相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签