外部主机上的会话变得混乱

发布于 2024-09-27 10:31:43 字数 350 浏览 7 评论 0原文

问题听起来像这样: 使用会话登录在我的本地主机上工作得很好,但是当完全相同的文件上传到我的主机(hostgator)时,会话不会,或者它们会变得混乱。此外,注销功能在主机上不起作用。

我检查过,每个页面都有 session_start();在里面。

即使我的 logout.php 看起来像这样,会话也不会被破坏:

<?php
session_start(); 
$_SESSION = array();
session_unset();
session_destroy();
header("location:index.php");
exit();
?>

有什么建议吗?

The problem sounds like this:
The log-in using sessions works perfect on my localhost, but when the EXACTLY same files are uploaded to my host (hostgator), the sessions don't or, or they get messed up. Also the log-out feature doesn't work on the host.

I've checked and every page has the session_start(); inside it.

The session is not destroyed, even if my logout.php looks like this:

<?php
session_start(); 
$_SESSION = array();
session_unset();
session_destroy();
header("location:index.php");
exit();
?>

Any suggestions?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风渺 2024-10-04 10:31:43

我在带有 Firebug 的 Firefox 上注意到您的页面都被缓存了。您的会话工作正常,但您的页面被缓存,使登录和注销变得相当(混乱)。

禁用动态页面的 HTTP 缓存。

请参阅 Firebug 输出:

响应标头

HTTP/1.1 304 Not Modified
Date: Thu, 14 Oct 2010 13:16:50 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Expires: Thu, 14 Oct 2010 16:16:50 GMT
Cache-Control: public, max-age=10800

请求标头

GET / HTTP/1.1
Host: www.piataterenuri.info
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: PHPSESSID=55aea3f792334052dc673f85feb0b54a
If-Modified-Since: Wed, 13 Oct 2010 13:47:53 GMT
Cache-Control: max-age=0

PHP 手册已经有一个关于如何禁用缓存的示例:

http://php.net/manual/en/function.header.php< /a>


<?php

header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

?>

I noticed on Firefox with Firebug that your pages are all cached . Your session is working fine, but your page are cached, making login and logout quite (messed up).

Disable HTTP caching for your dynamic pages.

See Firebug output:

Response Headers

HTTP/1.1 304 Not Modified
Date: Thu, 14 Oct 2010 13:16:50 GMT
Server: Apache mod_fcgid/2.3.5 mod_auth_passthrough/2.1 mod_bwlimited/1.4 FrontPage/5.0.2.2635
Connection: Keep-Alive
Keep-Alive: timeout=5, max=100
Expires: Thu, 14 Oct 2010 16:16:50 GMT
Cache-Control: public, max-age=10800

Request Headers

GET / HTTP/1.1
Host: www.piataterenuri.info
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip,deflate
Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Keep-Alive: 115
Connection: keep-alive
Cookie: PHPSESSID=55aea3f792334052dc673f85feb0b54a
If-Modified-Since: Wed, 13 Oct 2010 13:47:53 GMT
Cache-Control: max-age=0

PHP manual has already an example on how to disable caching:

http://php.net/manual/en/function.header.php

<?php

header("Cache-Control: no-cache, must-revalidate"); 
header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past

?>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文