【发布时间】:2014-07-24 14:43:57
【问题描述】:
我们有一台 Amazon linux 服务器在过去 3-4 个月内从未使用过,当我们开始使用它时,用 PHP 编写的登录模块已完全损坏。当我检查标准 httpd 日志 /var/log/httpd/error_log 时,它说:
PHP 警告:session_start(): php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/sites/siteAdmin/authenticate.php on line 1
我被提到了很多关于这个的问题(关于 stackoverflow)、文章和博客,但没有一个对我有用。请帮忙。
验证.php
session_start();
global $dbname,$dbserver,$dbusername,$dbpasswd,$_SERVER;
include_once($_SERVER['DOCUMENT_ROOT']."/includes/_db_config.php");
$db = mysql_connect($dbserver,$dbusername,$dbpasswd);
mysql_select_db($dbname,$db);
$msg = "";
$userName=$_REQUEST["userName"];
$password=$_REQUEST["password"];
$sql_result2 = mysql_query("select * from TBL where user = '$userName' and pass = '$password'", $db);
$rs2 = mysql_fetch_array($sql_result2);
if(count($rs2)>0){
$adminId=$rs2[0];
$_SESSION["adminId"] = $adminId;
$_SESSION["loggedInFlag"] = 1;
header("Location:main.php");
exit();
}
else{
header("Location:URL");
exit();
}
session.* 来自 phpinfo()
Directive Local Value Master Value
session.auto_start Off Off
session.bug_compat_42 Off Off
session.bug_compat_warn On On
session.cache_expire 180 180
session.cache_limiter nocache nocache
session.cookie_domain .URL .URL
session.cookie_httponly Off Off
session.cookie_lifetime 0 0
session.cookie_path / /
session.cookie_secure Off Off
session.entropy_file no value no value
session.entropy_length 0 0
session.gc_divisor 1000 1000
session.gc_maxlifetime 28800 28800
session.gc_probability 1 1
session.hash_bits_per_character 5 5
session.hash_function 0 0
session.name PHPSESSID PHPSESSID
session.referer_check no value no value
session.save_handler Memcache Memcache
session.save_path tcp://URL:11111?persistent=1&weight=1&timeout=1&retry_interval=15
session.serialize_handler php php
session.use_cookies On On
session.use_only_cookies On On
session.use_trans_sid 0 0
【问题讨论】:
-
我只是试着写了几行代码 {session_start(); echo session_id();},但它不起作用。它没有显示任何内容
-
我的意思是:
I have been referred to so many questions(on stackoverflow), articles and blogs regarding this, none of them worked for me,了解您尝试解决问题的方法以及为什么它不起作用可能会很有用。 :) -
一下子发现DNS可能有问题,于是刷了DNS。然后我尝试重置我的 session_path。然后我把 PHP 从 5.3.1 升级到了 5.3.6,但是也没用。
-
在尝试会话内容之前,您是否将
ini_set('display_errors', true);放在脚本的顶部? -
顺便说一句,您的代码非常不安全,并且显示了 SQL 注入的完美路径。