如何在GoDaddy网站上正确使用session_start() [英] how to use session_start() properly on GoDaddy site

查看:75
本文介绍了如何在GoDaddy网站上正确使用session_start()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

修正以下问题:我的问题与标题已发送"无关.那仅仅是问题的征兆. 问题最终成为GoDaddy的一个严重问题,因为文件夹末尾丢失了.

Fix Below My problem had nothing to do with headers having "already been sent". That was simply a symptom of the problem. The problem ended up being a sever side issue with GoDaddy as a folder was missing on their end.

我已经修改了问题的名称,以包括"GoDaddy网站",以便将来帮助遇到相同问题的人.

I have edited my question's name to include "GoDaddy site" to maybe help someone in the future having the same issue.

根据@KennyPowers的建议,我打电话给Go Daddy.我最初有一个Windows托管帐户,然后切换到linux.显然,默认情况下session_start()保存到的文件夹没有随我的网站其余部分一起迁移,不,您不能更改默认文件夹..至少在我的网站上没有.

Per @KennyPowers suggestion I called Go Daddy. I originally had a windows hosted account and switched to linux. Apparently the folder that session_start() saves to by default did not migrate with the rest of my site, and no you cant change the default folder..at least not on my site.

GoDaddy替换了文件夹的末端,现在一切正常

GoDaddy replaced the folder on their end and everything works fine now

原始问题:

我可以使用 session_start()

网站流量:

  • page1.html 的表单可以发布到page2.php
  • page2.php 对数据进行了一些处理,并提供了链接到 page3.php
  • page3.php 加载时,需要来自 表格
  • page1.html has a form which POSTs to page2.php
  • page2.php does some stuff with the data and presents a link to page3.php
  • when page3.php loads it also needs to do something with the data from the form

所有页面都在同一个域中,所以我试图使用session_start()

All pages are on the same domain so Im trying to do this with session_start()

这是我尝试过的:

<?php
// page2.php

session_start();

echo 'Welcome to page #2';

$_SESSION["guest1Last"] = $_POST["guest1Last"];
$_SESSION["guest1First"] = $_POST["guest1First"];
$_SESSION["guest1Middle"] = $_POST ["guest1Middle"];

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Title</title>
// more HTML and PHP stuff down here

第3页:

<?php
// page3.php

session_start();

echo 'Welcome to page #3<br />';


echo $_SESSION["guest1First"];  
echo $_SESSION["guest1Middle"];
echo $_SESSION["guest1Last"]; 

?>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
// more HTML and PHP stuff down here

以下是我在加载第2页时收到的警告: (第3页上的相同内容)

These are the warnings I get when page 2 loads: (same thing on page3)

Warning: session_start() [function.session-start]: open(/var/chroot/home/content/08/10125908/tmp/sess_3dt4c7etqd6hr28dls0bludiv4, O_RDWR) failed: No such file or directory (2) in /home/content/08/10125908/html/_php/page2.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cookie - headers already sent by (output started at /home/content/08/10125908/html/_php/page2.php:4) in /home/content/08/10125908/html/_php/page2.php on line 4

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/content/08/10125908/html/_php/page2.php:4) in /home/content/08/10125908/html/_php/page2.php on line 4
Welcome to page #2





Warning: Unknown: open(/var/chroot/home/content/08/10125908/tmp/sess_3dt4c7etqd6hr28dls0bludiv4, 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

标题已发送" 部分使我认为session_start()在页面上的位置不正确,但在我认为应该在顶部的位置.也就是说,出于明显的原因,似乎很可能是问题开始的地方" 没有这样的文件或目录 ".如果有人能指出我在做错事的方向,我将不胜感激.

The "headers already sent" part makes me think session_start() is not in the right place on the page but its at the top where I believe it should be. That said it seams likely that "No such file or directory" is where the problem is starting, for obvious reasons. I would greatly appreciate if someone could point me in the direction of what i am doing wrong.

编辑

<?php
session_start();
ini_set('session.save_path', '/var/chroot/home/content/08/10125908/html/tmp');
echo 'Welcome to page #1';

$_SESSION["guest1Last"] = $_POST["guest1Last"];
$_SESSION["guest1First"] = $_POST["guest1First"];
$_SESSION["guest1Middle"] = $_POST ["guest1Middle"];



?>

  • 我创建了一个tmp文件夹并授予了所有权限
  • 我添加了ini_set('session.save_path', '/var/chroot/home/content/08/10125908/html/tmp');
  • 并尝试了ini_set('session.save_path','html/tmp');
  • 我还创建了一个文本文件 session_save_path('/home/content/04/8260904/html/tmp');保存了它 为 php.ini ,并将其上传到我的根目录
  • 我也用
    创建了一个文本文件 session_save_path('/home/content/04/8260904/html/tmp');保存了它
    php5.ini ,并将其上传到我的根目录
    • I created a folder tmp and gave it all permissions
    • I added ini_set('session.save_path', '/var/chroot/home/content/08/10125908/html/tmp');
    • and tried ini_set('session.save_path', 'html/tmp');
    • I also created a text file with session_save_path('/home/content/04/8260904/html/tmp'); saved it as php.ini and uploaded it to my root
    • I also I also created a text file with
      session_save_path('/home/content/04/8260904/html/tmp'); saved it
      as php5.ini and uploaded it to my root
    • 我仍然遇到相同的错误

       Warning: session_start() [function.session-start]: open(/var/chroot/home/content/08/10125908/tmp/sess_3659a32a50e33e5f918a9e39d70a1668, O_RDWR) failed: No such file or directory  
      

      我没有正确设置文件夹目的地吗?

      am I not setting the folder destination correctly?

      立即设置我的文件夹

      根据@KennyPowers的建议,我打电话给Go Daddy.我最初有一个Windows托管帐户,然后切换到linux.显然,该文件夹未随我网站的其余部分一起迁移,不,您无法更改默认文件夹..至少不在我的网站上.

      Per @KennyPowers suggestion I called Go Daddy. I originally had a windows hosted account and switched to linux. Apparently that folder did not migrate with the rest of my site, and no you cant change the default folder..at least not on my site.

      推荐答案

      您遇到的问题是您没有tmp.第一个错误说明了这一点:

      The problem you have is that you don't have tmp. The first error says about that:

      Warning: session_start() [function.session-start]: open(/var/chroot/home/content/08/10125908/tmp/sess_3dt4c7etqd6hr28dls0bludiv4, O_RDWR) failed: No such file or directory (2) in /home/content/08/10125908/html/_php/page2.php on line 4
      

      这就是为什么会话无法开始的原因.请参阅" ...失败:..中没有此类文件或目录(2)."

      That's why the session can't start. See "...failed: No such file or directory (2) in.."

      您需要创建/var/chroot/home/content/08/10125908/tmp/并在该目录上设置读/写权限. 您可以使用php脚本中的下一个函数来更改会话临时目录:

      You need to create /var/chroot/home/content/08/10125908/tmp/ and set read/write permission on that directory. You can change session temp direcotry by using the next function from your php script:

      ini_set('session.save_path', '/session/directory/goes/here');
      

      在收到此警告后,您会收到警告,告诉您有一些数据发送回了浏览器-这实际上是第一个警告文本.修复tmp目录问题后,它将立即得到解决.

      The warnings you get after this one tell you that there was some data sent back to your browser - which was actually the first warning text. It will be fixed right after you fix tmp directory issue.

      这篇关于如何在GoDaddy网站上正确使用session_start()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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