dongsha9208 2014-02-01 05:44
浏览 79
已采纳

两个单独页面的不需要的独立会话

I am stumped. Everybody says if you use session_start that you should get a single session even when you open multiple browser windows. However, it seems that my sessions are page specific.

When I load page one (index.php), it gives as a Session ID: sr51j9hhrjjrvbrfboek15l4e4 with an empty $_SESSION array

I then log in on a webpage (login.php) that generates a new Session ID: v2t8844nglg7uvnsrbr6k9ms43 with a $_SESSION array with various variables.

When I then reload page one, it will display the old session ID, not the new one as expected. It is page linked because if I copy load page two in tab one, it will give the same session ID as the page in tab 2, and visa versa.

I have added the rule

CacheDisable /local_files

to the httpd.conf file with no effect.

I uses Apache 2.4 (XAMPP installation for windows), with the http://php-login.net advanced login script.

Top of page (before the HTML tag):

session_start();

require_once('includes/connection.php');

followed by:

echo var_dump($_SESSION);

echo session_save_path();

echo 'Session ID: '.session_id();

at the top of the page in the body tag. Any suggestions?

  • 写回答

2条回答 默认 最新

  • duanfei7508 2014-02-01 06:19
    关注

    Okay, found the answer here: My session ID's stopped working

    One page was localhost:8001, while the second was 127.0.0.1:8001, which are treated by the server as two separate pages for the purpose of sessions, while serving the same page.

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

报告相同问题?

悬赏问题

  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?