I have big problem related to login. actually some time it work fine but some time not working. I have setting.php in which session_start() is executing. this file is including in all file. another file is config.php where all variable is defined including session name
$siteConfig_session_name = dhoombox ;
然后创建了一个类用户,其中有如下函数userlogin:-
function user_front_end_login($_POST,$checkout_page,$check){
$errorMessage = ;
$userName = trim($_POST[ username ]);
$password = md5(trim($_POST[ password ]));
$user_login = mysql_query("SELECT user_id, email_id,username, password , firstname, lastname, status FROM tbl_users WHERE username= ".$userName." AND password = ".$password." ");
$select_user = mysql_fetch_array($user_login);
if( mysql_num_rows($user_login)==1){
$user_status = $select_user[ status ];
//setAdminError( <span class="errormsg">Information has not been deleted!</span> );
if( $user_status==1){
$this->setUserLoginSession($select_user[ user_id ], $select_user[ email_id ], $select_user[ username ],$select_user[ firstname ],$select_user[ lastname ]);
if($checkout_page==1){
siteRedirect("billing_info.php");
}
else{
print_r($_SESSION);
siteRedirect("index.php");
}
}else{
setAdminError( <span class="errormsg" style="color:#FF0000;">Sorry your account is not activated.</span> ); siteRedirect("login.php");
}
}else{
setAdminError( <span class="errormsg" style="color:#FF0000;">Username or password mismatch</span> );
if($checkout_page==1){
siteRedirect("checkout.php");
}
else{
siteRedirect("login.php");
}
}
}
$this->;setUserLoginSession($select_user[user_id]、$select_user[email_id]、$select_user[用户名]、$sectit_user[名字]、$Sectit_user[姓氏]);如下所示:-
function setUserLoginSession($uid, $email, $un, $fn,$ln) {
global $siteConfig_session_name;
$_SESSION[ user_id ] = $uid;
$_SESSION[ email_id ] = $email;
$_SESSION[ username ] = $un;
$_SESSION[ firstname ] = $fn;
$_SESSION[ lastname ] = $ln;
}
有时它工作良好,有时则不然。