dongxie3963 2013-08-28 00:50
浏览 65
已采纳

localhost上的跨子域PHPSESSID

I am on Windows 7 using WAMP, and I am trying to share the PHPSESSID across subdomains.

In my code I set: ini_set('session.cookie_domain', '.web.local');

When I go to test.web.local I get a different PHPSESSID than web.local

I want to be able to share the PHPSESSID in $_COOKIE accross the subdomains.

What am I doing wrong?

  • Also running Wildcard based subdomains via Acrylic DNS Proxy custom hosts file.
  • Another thing, if I echo phpinfo() on both domains, the session.cookie_domain directive has the same value on both.
  • 写回答

1条回答 默认 最新

  • drpjdfj618393 2013-08-28 01:20
    关注

    I believe you need to use session_set_cookie_params to share session across subdomain and you use need to use it on every pages (use it on main domain and subdomain). For example:

    session_set_cookie_params(0, '/', '.web.local');    
    session_start();
    

    Noted that you need to use it before session_start(). For more information. Read the session_set_cookie_params documentation here.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 oracle集群安装出bug
  • ¥15 关于#python#的问题:自动化测试