dongpa3109 2014-05-14 11:58
浏览 32

如何在子域中使用php会话[重复]

This question already has an answer here:

I have one domain and sub domain as bellow,

domain-name.local
sub.domain-name.local

I have a login system in domain-name.local and I need to use same sessions to validate while accessing sub.domain-name.local.

As mention in the question I have tried following things in sub domain without success,


Set php.ini session.cookie_domain as .domain-name.local

Results :

firefox- worked ie- not loading while accessing the session from sub domain chrome - not giving any session details


set from php code as bellow

    ini_set('session.cookie_domain', '.domain-name.local');
    session_start();
    var_dump($_SESSION);

Results :

firefox - not giving any session details , ie- not loading while accessing the session from sub domain, chrome - not giving any session details


another php code as suggest in that question,

    session_set_cookie_params(0, '/', '.domain-name.local');
    session_start();
    var_dump($_SESSION);

Results : same as second


Any help would be appreciate since i'm stuck here for long time.


EDIT :

When I checked the cookies, I can see two PHPSESSID was created. I think that is the issue. I need to use the same PHPSESSID from the main.


EDIT 2

When I set the session.cookie_domain to .domain-name.local from the php.ini or .htaccess, everything is working fine except in the IE(ie 10/win 8). In IE sometimes session can access sometime web page totally not accessible(keep loading but no result for minutes).

Does anyone was having same experience on the same issue.

</div>
  • 写回答

2条回答 默认 最新

  • dongyi3776 2014-05-14 12:00
    关注

    You should try to regenerate the session id:

    session_regenerate_id(true);
    
    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度