我有两个PHP
文件,我想在其中存储一个像这样的session
变量id
if(authentification($login,$mdp) == 0)
{?>
<script>alert('logging failed');</script>
<?php
header('Location: Contacts.php');
}
else{
session_start();
$_SESSION['login'] = $login;
$_SESSION['mdp'] = $mdp;
$a = authentification($login,$mdp);;
$_SESSION['id'] = $a;
header('Location: space.php');
}
并且在文件中space.php
session_start();
$list = Get_companies_by_user($_SESSION['id']);
在里面function.php
function authentification($login,$mdp){
parametrs();
$Log_query=mysql_query(
"
SELECT user_id
FROM reg_users
WHERE username ='$login'
AND password ='$mdp'
") or die(mysql_error());
if ($Log_query == true && mysql_num_rows($Log_query) >0) {
while ($Res_user = mysql_fetch_array($Log_query) ) {
return $Res_user;
}
}
else return 0;
}
问题在于变量的值$_SESSION['id']
:为什么它是空值space.php
?我该如何解决这个错误?