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

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

报告相同问题?

悬赏问题

  • ¥15 win2012磁盘空间不足,c盘正常,d盘无法写入
  • ¥15 用土力学知识进行土坡稳定性分析与挡土墙设计
  • ¥70 PlayWright在Java上连接CDP关联本地Chrome启动失败,貌似是Windows端口转发问题
  • ¥15 帮我写一个c++工程
  • ¥30 Eclipse官网打不开,官网首页进不去,显示无法访问此页面,求解决方法
  • ¥15 关于smbclient 库的使用
  • ¥15 微信小程序协议怎么写
  • ¥15 c语言怎么用printf(“\b \b”)与getch()实现黑框里写入与删除?
  • ¥20 怎么用dlib库的算法识别小麦病虫害
  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启