douya7309 2013-01-15 14:13
浏览 9
已采纳

在expressionengine上的PHP本机会话问题

I am using sessions for my expressionengine project. I have used the following methods to set sessions at the top of the page.

    if (session_id() == ''){
         session_start(); 
    } or

   if(!isset($_SESSION)){
        session_start();
    }

      or

   if(empty($_SESSION['userid'])){
      session_start(); 
   } 

I have written custom expression engine plugin where I do session check.

After sometime I observed a strange behaviour of sessions. It is getting set different for different url. for http:// url it sets differently and for www:// url it sets differently. How do I set and retrieve sessions such that both http://example.com and www.example.com will yeild same result.

I have followed steps from this url as well http://ellislab.com/forums/viewthread/231468/. I have posted the same issue on http://ellislab.com/forums/viewthread/232604/. But its not helping me.

Can someone help me on this.

  • 写回答

2条回答 默认 最新

  • doubu4826 2013-01-15 15:05
    关注

    Thanks @mishu. After you explained that www was a subdomain and a session_cookie problem, I did some experimentation and then googled a bit.

    This post on stackoverflow was very helpful. PHP Sessions across sub domains

    I opened the index.php file on root folder of expressionengine / codeigniter and then added the below line

    ini_set('session.cookie_domain','.example.com');
    

    Now its working fine. If someone could explain briefly on this thread, it will be of great use to other developers.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

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