从主域访问子域会话 [英] Access subdomain session from main domain

查看:117
本文介绍了从主域访问子域会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个在mydomain.com的应用程序。我希望在登录到 mydomain.com 时,用户将被重定向到 example.mydomain.com ,但会话在 example.mydomain.com 。现在我的问题是提交登录后,用户无法登录 example.mydomain.com 。虽然有会话文件可用。

I have an application in mydomain.com. I want user will be redirected to example.mydomain.com when login to mydomain.com, however session successfully generating in a directory at example.mydomain.com. Now my problem is after submit login, users are not able to login example.mydomain.com. Although there are session files are available.

会话驱动程序是文件(mydoman.com配置文件)

Session driver is file (mydoman.com config file)

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 0;
$config['sess_save_path'] = 'mydir/application/session_data';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 0;
$config['sess_regenerate_destroy'] = FALSE;

我的应用程序在本地服务器中正常工作。但不是在生产中工作。

My application working fine in local server. But not working in production.

推荐答案

您还必须设置 cookie_domain cookie前缀在您的配置文件中像这样

You also have to set the cookie_domain and cookie prefix in your config file like this

$config['cookie_prefix'] = "mydomain_";
$config['cookie_domain'] = ".mydomain.com";
$config['cookie_path'] = "/";
$config['cookie_secure'] = FALSE;

这篇关于从主域访问子域会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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