我正在用 php 编写登录页面,但在设置 $_SESSION 时遇到问题。我是 php 新手,我不知道我做错了什么。该脚本在本地主机上运行良好,但是当我将其推送到远程服务器时,它不起作用。可能是 php.ini 文件吗?谢谢你的帮助。
<?
start_session();
$dbc = mysqli_connect($host,$name,$dpassword,$database) or die('Error can not connect to corp database');
$q="SELECT * FROM corporate WHERE (email='$theemail' AND password='$md5pass' AND activated = '1')";
$result= mysqli_query($dbc,$q) or die("Error: ".mysqli_error($dbc));;
if(@mysqli_num_rows($result) == 1)
{
//get the entire row
$getrow = mysqli_fetch_array($result);
//also tired
//$_SESSION = mysqli_fetch_array($result, MYSQLI_ASSOC);
//set session, but does not get set!
$_SESSION['lname'] = $getrow['lname'];
$_SESSION['fname'] = $getrow['fname'];
//set cookie for an hour
setcookie("lname", $getrow['lname'], time()+60*60,"/","http://www.limozoor.com",1);
setcookie("fname",$getrow['fname'],time()+60*60,"/","http://www.limozoor.com",1);
//if no header is not sent, send it.
if(!headers_sent())
{
header('Location: http://www.limozoor.com/login/homepage.php');
exit();
}//inner
}//outter
}
?>
php.ini
[Session]
session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.name = sid
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.serialize_handler = php
session.gc_divisor = 100
session.gc_maxlifetime = 1440
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 1