问题描述
我使用 Yii 框架,并且在该框架中我使用了 mibew Messenger(或 chat)的第 3 方应用程序.
我需要的是将 $_session
变量(用户名和密码)从 yii 框架传递给 Mibew messenger,我需要这个,因为我想在什么时候自动登录我登录到我的 yii 应用程序.
Mibew messenger 文件夹位于应用程序的 app 文件夹中.
那么如何在 yii 框架 之外使用相同的会话?
感谢您的帮助.
我认为您可以执行以下操作:
1) 在您需要访问 SESSION 的第 3 方应用程序文件中:
require('/path/to/framework/YiiBase.php');
2) 如果您有特定的会话配置,那么您需要配置:
$config = require('/path/to/protected/config/main.php');$session = YiiBase::createComponent($config['components']['session']);
3) 对于标准会话(而不是第 2 步),您应该尝试:
$session = new CHttpSession();
您可以像在框架中一样使用会话:$session[$var_name]
或 $session->get/set($var_name)
.
我不检查它的解决方案.如果有错误 - 写在评论中.
更新
只需要做:
require('/path/to/framework/YiiBase.php');$config = require('/path/to/configs_directory/main.php');Yii::createWebApplication($config);
你可以通过 Yii::app()
I use Yii framework and in the framework i use 3rd party application which is mibew Messenger (or chat ).
What I need is to pass $_session
variable (username and password) from yii framework to Mibew messenger, I need this because I want to be log in automatically when I log in into my yii application.
Mibew messenger folder is in the app folder of the application.
So how can I use the same session outside of yii framework ?
Thanks for the help.
I think you may do following:
1) In file of 3rd party application where you need to get an access to SESSION:
2) If you have specific configs for sessions, than you need you configs:
3) For standard sessions (instead step #2) you should try:
Than you can work with sessions as in framework: $session[$var_name]
or $session->get/set($var_name)
.
I don't check it solution. If there will be an error - write it on comments.
UPDATED
Just need to do:
Than you can use all framework features by Yii::app()
这篇关于我如何将 yii 框架中的会话用于我的 3rd 方应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!