$ _SESSION问题 - 页面重新加载会创建新的会话ID [英] $_SESSION problem - page reload creates new Session ID

查看:103
本文介绍了$ _SESSION问题 - 页面重新加载会创建新的会话ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我在使用会话变量时遇到问题

PHP 4.3.9

操作系统:Win XP教授

Web服务器IIS(本地并且没有其他服务器的链接来自我工作的网页


浏览器:IE 6.0

我遇到的问题是,每次重新加载相同的PHP页面时,我都会得到

a不同

会话ID (因此所有会话变量都会从一个页面丢失到另一个页面。)


让我们说在firstpage.php我设置

$ _SESSION [" ; firstvar"] =" someval";

$ _SESSION [" secvar"] =" otherval";


和secpage.php I尝试检索$ _SESSION [" firstvar"],它给了我

" Undefined Index error"

我不知道发生了什么,打印出会话时id(echo

SID;)我发现

每次重新加载页面或移动到
另一页。


问题是我不知道什么会重置会话,因为我使用

" session_auto_start" ;

并没有使用session_start,session_destroy或其他任何东西。


有人能给我一个暗示可能导致这种情况的原因吗?


谢谢


取自PHP_INFO的设置:

================= ================================= ========

会话支持启用

注册保存处理程序文件用户


指令本地值主值

session.auto_start On On

session.bug_compat_42 On On

session.bug_compat_warn On On

session.cache_expire 180 180

session.cache_limiter nocache nocache

session.cookie_domain没有价值没有价值

session.cookie_lifetime 0 0

session.cookie_path / /

session.cookie_secure关闭关闭

session.entropy_f没有价值没有价值

session.entropy_length 0 0

session.gc_divisor 100 100

session.gc_maxlifetime 1440 1440

session.gc_probability 1 1

session.name PHPSESSID PHPSESSID

session.referer_check没有值没有值

session.save_handler文件文件

session.save_path D:\PHP \SessionData D:\PHP \ SessionC

session.serialize_handler php php

session.use_cookies On在

session.use_only_cookies关闭

session.use_trans_sid关闭

解决方案

< blockquote> _SESSION [" firstvar"] =" someval";


_SESSION [" secvar"] =" otherval";

和secpage.php我尝试检索


_SESSION [" firstvar"],它给了我

" Undefined Index error"

我不知道发生了什么事当打印出会话ID时(回复

SID;)我发现

每次重新加载页面或移动到
$ b时ID都在变化$ b另一页。


问题是因为我使用

" session_auto_start"

并没有使用session_start,session_destroy或其他任何东西。


有人能给我一个暗示可能导致这种情况的原因吗?


谢谢


取自PHP_INFO的设置:

===================== ============================= ========

启用会话支持/>
注册保存处理程序文件用户


指令本地值主值

session.auto_start On On

session .bug_compat_42 On On

session.bug_compat_warn On On

session.cache_expire 180 180

session.cache_limiter nocache nocache

session.cookie_domain没有价值没有价值

session.cookie_lifetime 0 0

session.cookie_path / /

session.cookie_secure关闭

session .entropy_file没有值没有值

session.entropy_length 0 0

session.gc_divisor 100 100

session.gc_maxlifetime 1440 1440

session.gc_probability 1 1

session.name PHPSESSID PHPSESSID

session.referer_check没有值没有值

session.save_handler文件文件

session.save_path D:\PHP \SessionData D:\ PHP \SessionData

session.serialize_handler php php

session.use_cookies On On

session.use_only_cookies Off Off

session.use_trans_sid Off Off


Hello,

I am having trouble using the session vars in
PHP 4.3.9
OS: Win XP Prof
Web Server IIS (is local and there are no links to other servers from
the web pages I work on)
Browser: IE 6.0

The problem I am having is that each time I reload the same PHP page, I get
a different
Session ID (and thus all session vars are lost from one page to another).

let''s say in firstpage.php I set
$_SESSION["firstvar"] = "someval";
$_SESSION["secvar"] = "otherval";

and in secpage.php I try to retrieve $_SESSION["firstvar"] , it gives me
"Undefined Index error"
I did not know what is happening and when printing out the session id (echo
SID;) I found out
that the ID is changing every time page is reloaded or when moving to
another page.

The problem is that I don''t know what might reset the session since I use
"session_auto_start"
and have not played with session_start, session_destroy or anything else.

Can someone give me a hint on what might cause this ?

Thanks

Settings taken from PHP_INFO:
================================================== ========
Session Support enabled
Registered save handlers files user

Directive Local Value Master Value
session.auto_start On On
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path D:\PHP\SessionData D:\PHP\SessionData
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off

解决方案

_SESSION["firstvar"] = "someval";


_SESSION["secvar"] = "otherval";

and in secpage.php I try to retrieve


_SESSION["firstvar"] , it gives me
"Undefined Index error"
I did not know what is happening and when printing out the session id (echo
SID;) I found out
that the ID is changing every time page is reloaded or when moving to
another page.

The problem is that I don''t know what might reset the session since I use
"session_auto_start"
and have not played with session_start, session_destroy or anything else.

Can someone give me a hint on what might cause this ?

Thanks

Settings taken from PHP_INFO:
================================================== ========
Session Support enabled
Registered save handlers files user

Directive Local Value Master Value
session.auto_start On On
session.bug_compat_42 On On
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain no value no value
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 100 100
session.gc_maxlifetime 1440 1440
session.gc_probability 1 1
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler files files
session.save_path D:\PHP\SessionData D:\PHP\SessionData
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies Off Off
session.use_trans_sid Off Off


这篇关于$ _SESSION问题 - 页面重新加载会创建新的会话ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆