我正在尝试做一个饼干。它没有成功。
此代码有效,但在最近的系统中不起作用。login_check.html 如下。
<?
include "../_cfg/siteCfg.php"; //Site common values
include "$SITE_PATH/_class/dbms.php"; //mysql_class
include "$SITE_PATH/_class/Function.php";
$my_func = new PublicFunction();
$db = new mydb(); //DB Access
if ( $HTTP_POST_VARS[id] && $HTTP_POST_VARS[passwd] ) {
$sql = "select uid, passwd, m_id, name, level from member_list where m_id = '$HTTP_POST_VARS[id]'";
$result = $db->select($sql);
if ( !$result ) {
$my_func->virtual_function( "login_error ('ID_ERR')" );
}
else if ( $HTTP_POST_VARS[passwd] != $result[0][1] ) {
$my_func->virtual_function( "login_error ('PW_ERR')" );
}
else if ( $result && ( $HTTP_POST_VARS[passwd] == $result[0][1] )) {
$m_id = $result[0][m_id];
$uid = $result[0][uid];
$name = $result[0][name];
$level = $result[0][level];
setcookie("c_m_id",$m_id,0,'/');
setcookie("c_uid",$uid,0,'/');
setcookie("c_name",$name,0,'/');
setcookie("c_level",$level,0,'/');
$my_func->virtual_function("alert($_COOKIE[c_level])"); // This is for a log
$my_func->virtual_function( "loginOk()" );
}
} else {
$my_func->virtual_function("alert('Bad Access!!!')");
}
?>
当我提醒检查 COOKIE 值时,它为空。
我使用了 var_dump(isset($_COOKIE[c_uid]));, ant 然后它返回 bool(false) 。
另外我更改了标题@header('P3P: CP="ALL CURa ADMa DEVA TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC"'); to header('P3P: CP="NOI CURa ADMa DEVa TAIa OUR DELa BUS IND PHY ONL UNI COM NAV INT DEM PRE"'); .
这也不起作用。
此代码由以下调用。上面的代码是login.html
<?
require_once "$DOCUMENT_ROOT/_cfg/siteCfg.php"; //site value
require_once "$SITE_PATH/_class/htmlHead.php";
$title = "Login"; //title value
$htmlTPL = new htmlTPL($title); //HEAD Instance creation
?>
<title></title>
<link href="<?=$SITE_HOME?>/_styles/style.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="<?=$SITE_HOME?>/_js/common.js"></script>
<script>
//<!--
function login_check(){
var fm = document.login_form;
fm.target = "vr_url";
fm.action = "./login_check.html";
fm.submit();
}
function login_error ( num ) {
fm = document.login_form;
if ( num == "ID_ERR" ) {
alert ( "Not registered user.");
fm.passwd.value = "";
fm.id.focus();
fm.id.select();
} else if ( num == "PW_ERR" ) {
alert ( "Wrond Pasword." );
fm.passwd.focus();
fm.passwd.select();
}
}
function loginOk(){
opener.location.reload(true);
window.close();
}
//-->
</script>
这是 siteCfg.php 的一部分
<?
//@header("Cache-Control: no-cache,must-revalidate");
//@header ("Pragma: no-cache");
@header('P3P: CP="ALL CURa ADMa DEVa TAIa OUR BUS IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC OTC"');
//header('P3P: CP="NOI CURa ADMa DEVa TAIa OUR DELa BUS IND PHY ONL UNI COM NAV INT DEM PRE"');
//error_reporting(E_ALL);
$SITE_PATH = $DOCUMENT_ROOT;
$IMG_PATH = $SITE_PATH."/image";
$MANAGER_PATH = $SITE_PATH."/manager";
$SITE_HOME = 'http://www.mysite.com';
$MANAGER_HOME = $SITE_HOME."/manager";
$IMAGE_HOME = $SITE_HOME."/image";
$ADMIN_HOME = $SITE_HOME."/manager_admin";
//Login Return URL
$PREURL = urlencode($SITE_HOME.$_SERVER["REQUEST_URI"]);
//Values Setting
$_name = $_COOKIE[c_name];
$_mid = $_COOKIE[c_m_id];
$_uid = $_COOKIE[c_uid];
$_mlevel = $_COOKIE[c_level];
//var_dump(isset($_name));
//FTP Setting
PHP 版本 5.2.17 。有什么我可以检查来解决这个问题的。请告诉我。我在 IE 11、Chrome 30.0.1599.101 m、Firefox、Safari 上进行了测试。根本不工作