doukucai0099 2013-05-19 02:29
浏览 21

too long

There is session data being saved on sub.domain.com and I'd like to use that data in domain.com.

I confirmed that they both have the same session save path (by echoing ini_get('session.save_path') in both)

I've tried putting ini_set('session.cookie_domain', '.sub.domain'); on domain.com but that didn't work. (I have also removed the preceding .).

I also tried adding session_set_cookie_params(0, '/', '.domain.com'); in front of each session_start(), but that didn't work either.

I would like to be able to use the $_SESSION data in domain.com from what is set in sub.domain.com.

What can I do for this to work?

Thanks!


UPDATE: I figured out (at least one way) of how to do this, but not sure why my answer works. I guess my question would now be, Why does renaming the session name solve this? using the same session cookie domain (?) makes more sense to me.
Seems like setting this domain creates a new session $_SESSION['domain'] (where 'domain' is interchangeable in the session_name('domain') function.)
  • 写回答

1条回答 默认 最新

  • doushuangdui5419 2013-05-19 02:51
    关注

    adding the following to each file fixed this:

    session_name("domain");
    session_set_cookie_params(0, '/', '.domain.com');
    session_start();
    

    Does anyone know why re-naming the session fixes this? It's that first line that made this all work.

    评论

报告相同问题?

悬赏问题

  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)