gpt4 book ai didi

PHP - Can't start session suddenly on GoDaddy website(PHP-无法在GoPardy网站上突然启动会话)

转载 作者:bug小助手 更新时间:2023-10-24 21:25:13 26 4
gpt4 key购买 nike



I had a perfectly functional GoDaddy website (under development) before Christmas break. It has not been changed. Today, I logged on and I have all these strange errors regarding sessions that weren't there before.

在圣诞节之前,我有一个功能完善的谷歌爸爸网站(正在开发中)。它没有被改变。今天,我登录了,我遇到了所有关于以前没有的会话的奇怪错误。



To investigate, I made a new file and threw it on the site with the contents:

为了进行调查,我制作了一个新文件,并将其与内容一起放在网站上:



<?PHP
session_start();
echo "HELLO WORLD!";
?>


Navigating to this page in a freshly opened browser gives the following output:

在新打开的浏览器中导航到此页面会显示以下输出:



Warning: session_start() [function.session-start]: open(/var/chroot/home/content/05/8547705/tmp/sess_m3uikb1qe6v5hsjir8ilsfa811, O_RDWR) failed: Permission denied (13) in /home/content/05/8547705/html/try.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/05/8547705/html/try.php:2) in /home/content/05/8547705/html/try.php on line 2

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/05/8547705/html/try.php:2) in /home/content/05/8547705/html/try.php on line 2
HELLO WORLD!
Warning: Unknown: open(/var/chroot/home/content/05/8547705/tmp/sess_m3uikb1qe6v5hsjir8ilsfa811, O_RDWR) failed: Permission denied (13) in Unknown on line 0

Warning: Unknown: Failed to write session data (files). Please verify that the current setting of session.save_path is correct () in Unknown on line 0


I don't even know where to start with this - does anyone know what could have changed to make this basic file not work?

我甚至不知道从哪里开始--有人知道是什么原因导致这个基本文件无法工作吗?


更多回答

This seems like a mistake on GoDaddy's part. Contact their customer support.

这似乎是谷歌爸爸的一个错误。联系他们的客户支持。

This seems to be a server issue. Perhaps a move to serverfault.com is in order?

这似乎是服务器问题。或许转向serverfault.com是合适的选择?

Recommendation: Get off GoDaddy (if possible), they don't have the best hosting. (I'd make a recommendation for a hosting provider but that wouldn't be appropriate here).

推荐:离开谷歌爸爸(如果可能的话),他们没有最好的主人。(我会推荐一家托管服务提供商,但在这里不太合适)。

优秀答案推荐

Haven't seen the first warning, but the others happen if the script sends headers or data before the call to session_start(). You can fix that by either:

我没有看到第一个警告,但如果脚本在调用Session_Start()之前发送标头或数据,则会出现其他警告。您可以通过以下任一方式进行修复:



1) making sure that there's no HTML or whitespace before session_start(), or,
2) using output buffering (see ob_start() and ob_end_flush().

1)确保SESSION_START()之前没有HTML或空格,或者,2)使用输出缓冲(参见ob_start()和ob_end_flush())。



With (2) you can start the session anytime during script execution; the buffering makes sure headers and response data are sent to the browser in the right order.

使用(2)可以在脚本执行期间的任何时间启动会话;缓冲确保头和响应数据以正确的顺序发送到浏览器。



Get rid of any white space before session_start()

在SESSION_START()之前清除所有空格



I know this post is very old, but maybe this will help someone.
I was getting the same type session errors. The session path in the errmsg did not exist. Yet, the session path in the CPanel configuration existed.
If you've had a old website at godaddy that's been migrated or updated to CPanel, you may have an old .user.ini file that is incorrectly setting the path for session that will conflict/override the one you can specify in CPanel.
Suggest commenting out the one in .user.ini and using the one in Cpanel.
The problem can also happen when you change versions of PHP as the session save path may have the php version in it. That is why you want to use the one in CPanel.
Probably good idea to examine the other settings in .user.ini and remove ones that are no longer necessary/can be set in CP.

我知道这篇文章很老了,但也许这篇文章会对某些人有所帮助。我收到了相同类型的会话错误。Errmsg中的会话路径不存在。然而,cPanel配置中的会话路径仍然存在。如果你有一个已经迁移或更新到cPanel的旧网站,你可能有一个旧的.user.ini文件,它错误地设置了会话的路径,这将冲突/覆盖你可以在cPanel中指定的路径。建议注释掉.user.ini中的那个,并使用Cpanel中的那个。当你改变php的版本时,这个问题也会发生,因为会话保存路径中可能有php版本。这就是为什么要使用cPanel中的那个。检查.user.ini中的其他设置并删除不再需要/可以在CP中设置的设置可能是个好主意。


更多回答

The 'headers already sent' warnings are simply byproducts of the first warning. After the Warning: session_start() [function.session-start]: open(/var/c... message has been displayed, clearly the headers have already been sent.

“邮件头已发送”警告只是第一个警告的副产品。警告后:SESSION_START()[Function.SESSION-START]:OPEN(/var/c...消息已显示,显然标头已发送。

Looks like godaddy got rid of the folder where PHP stores its sessions, or changed the permissions. As others have mentioned, contact support. You could also set an alternate sessions folder using session_save_path() but it would be better if they fixed their configuration issue.

看起来GoPardy删除了存储其会话的文件夹,或者更改了权限。正如其他人提到的,请联系支持人员。您也可以使用SESSION_SAVE_PATH()设置一个备用会话文件夹,但如果它们解决了配置问题就更好了。

I used session_save_path() to mitigate the errors and got in touch with GoDaddy to have them fix them (hopefully :/). Thanks for the solution :)

我使用SESSION_SAVE_PATH()来减少错误,并与GoPardy取得联系,让他们修复错误(希望是:/)。感谢您的解决方案:)

Why this should help? If the file is really the one posted, the whitespaces before the line 2 don't matter because they are inside the <?php tag.

为什么这应该会有帮助?如果文件确实是已发布的文件,则第2行之前的空格并不重要,因为它们位于<?php标记内。

@AurelioDeRosa: Actually, that could help. If there was an invisible character such as a BOM in the beginning of the file (before opening PHP), this could cause a 'headers already sent' error. This is, however, not the case here. That error is just a byproduct of the first error regarding insufficient access to a temp folder.

@AurelioDeRosa:事实上,这可能会有帮助。如果文件的开头有不可见的字符,如BOM(在打开PHP之前),这可能会导致‘Headers Always Sent’(标题已发送)错误。然而,这里的情况并非如此。该错误只是有关对临时文件夹访问权限不足的第一个错误的副产品。

I appreciate the suggestion, but there's no white space and the files I have on the real website didn't used to do this, so I figure its somehow configuration related but I don't know what to look for.

我很感激这个建议,但是没有空白,我在真正的网站上的文件也没有这样做,所以我认为它与配置有关,但我不知道该找什么。

No problem. Then I think it's a hosting/permissions problem. try calling godaddy. Or better yet, change hosting providers ;)

没问题。那么我认为这是一个托管/权限问题。试着给谷歌爸爸打个电话。或者更好的是,更换主机提供商;)

@KristianAntonsen Infact, as I said, the whitespaces before the line 2 don't matter if they're inside the <?php tag.

@KristianAntonsen事实上,正如我所说的,如果第2行之前的空格位于<?php标记内,则它们并不重要。

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com