doune1000 2015-04-21 21:12
浏览 57
已采纳

仅在GoDaddy上发出PHP Session问题(警告:session_start():无法发送会话cookie)

I am currently working on a user registration system for a client on GoDaddy hosting.

I have previously never had this sort of issue before on Hostgator and while testing locally on a PHP test server on OS X.

It's a fairly simple script too. common.php accesses the MySQL database, all of the pages (login, register, etc.) include common.php. Sessions start when the user logs in, etc.

I see the following errors at the top of the page:

Warning: session_start(): open(/home/content/10/12114910/tmp/sess_trmok9fgtb527mjp21a76shf54, O_RDWR) failed: No such file or directory (2) in /home/content/10/12114910/html/common.php on line 86

Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /home/content/10/12114910/html/common.php:86) in /home/content/10/12114910/html/common.php on line 86

Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /home/content/10/12114910/html/common.php:86) in /home/content/10/12114910/html/common.php on line 86

The following errors are at the bottom of the page.

Warning: Unknown: open(/home/content/10/12114910/tmp/sess_trmok9fgtb527mjp21a76shf54, O_RDWR) failed: No such file or directory (2) 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

Once again, this is only a GoDaddy issue. My client was originally on Windows hosting and this just did not even work at all and I switched them to Linux hosting.

They were on PHP version 5.3 and I changed it to 5.4 and I have still had no luck.

I have never messed with a php.ini file. Would I need to create one? I have heard that uploading it into the public_html folder overrides the one on the server even though we are on a shared hosting plan.

Would I also need SSH access to create a tmp folder and set proper permissions for it?

  • 写回答

1条回答 默认 最新

  • drqn5418 2015-04-21 21:23
    关注

    This is usually quite easy to fix on crappy providers (I don't recommend GoDaddy, by the way).

    Here is how I'd go about fixing it, hopefully it will help you.

    Step 1: Make a directory and call it _sessions or something of that nature.

    Step 2: Give it a chmod of 775 so that the web server can write to it.

    Step 3: On the first script that runs, right at the top place session_save_path("./_sessions");

    Step 4 (optional, but recommended): Add either deny from all in a .htaccess file to prevent people from getting to the directory, or simply chmod 776.

    Find out more about session_save_path() here: php.net/session_save_path

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统
  • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
  • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
  • ¥50 有数据,怎么用matlab求全要素生产率
  • ¥15 TI的insta-spin例程
  • ¥15 完成下列问题完成下列问题
  • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
  • ¥15 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!