奇怪的问题,放置 session_start() 会导致页面无法加载 [英] Weird issue, putting session_start() causes pages not to load

查看:28
本文介绍了奇怪的问题,放置 session_start() 会导致页面无法加载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

页面上有 session_start() 的所有页面都突然停止加载,并且已经像这样工作了多年.连房东都不知道该怎么办,求指教.

All pages that have session_start() on the page have suddenly stopped loading and it's been working for years like this. Even the host is unsure of what to do, looking for advise.

具有以下代码的示例测试页面也失败了:

A sample test page with the following code also failed:

error_reporting(1);
if(!$_REQUEST['disable']=="yes")
{

session_start();
}
echo "hello";

如果我在不传递参数的情况下调用页面?disable=yes 页面不会加载,它只是挂起处理

If I call the page without passing the parameters ?disable=yes the page doesn't load, it just hangs processing

该站点与服务器上的其他 2 个站点一起托管,其他 2 个站点没有任何问题,只是这个站点突然开始出现这种情况 [站点上没有更改任何代码现在 2 个月以上].

The site is hosted along with 2 other sites on the server, the other 2 don't have any issues, it's just this one site that has all of a sudden started acting like this [no code has been changed on the site for 2+ months now].

推荐答案

好的,我发现问题了!

猜猜看,它甚至与会话无关!虽然很令人惊讶的是 mysql 会导致会话出现此类问题.

And guess what, it's not even related to sessions! Although quite surprising that mysql can cause such issues with sessions.

发生了什么:

我设置了一个主数据库服务器和一个复制从数据库.我服务器中的大多数页面都试图连接到从站,如果从站失败,它将连接到主站.然而,由于一些奇怪的原因[我还没有想过],到从数据库的 mysql_connect 只是挂了而没有超时,而这反过来,出于某种奇怪的原因,不允许任何其他具有 session_start() 的页面加载!

I have a master DB server and a replication slave DB set up. Most of the pages in my server were trying to connect to the slave and if the slave failed, it would connect to the master. However, for some strange reason [which I haven't figured yet], the mysql_connect to the slave db just hung without timing out and this in turn, for some odd reason, wouldn't allow any other page which had session_start() to load!

现在我不确定为什么这会对所有其他页面产生这样的副作用,但我不得不禁用我的从服务器,将所有查询仅路由到主服务器,然后在我可以访问之前清除我的浏览器缓存再次访问该网站.

Now I am not sure as to why this would have such a side-effect on all other pages but I had to disable my slave server, routing all my queries only to the master and then cleared my browser cache before I could access the site again.

因此,如果 mysql_connect 连接到无法工作或无法连接到 [并且 mysql_connect 未超时] 的数据库,则可能会导致服务器上的任何其他页面无法加载 - 即使是一个简单的 4 行页面我在上面提出了我的问题,一个甚至不调用数据库的页面.

So a mysql_connect to a db that doesn't work or cannot be connected to [and with the mysql_connect not timing out], it can cause issues with any other page on your server from loading - even a simple 4 line page that I have put in my question above, a page that doesn't even call the DB.

这篇关于奇怪的问题,放置 session_start() 会导致页面无法加载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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