PHP会话变量don';行不通

PHP会话变量don';行不通,php,.htaccess,session,variables,Php,.htaccess,Session,Variables,每次使用登录脚本启动新会话时,会话变量都不起作用。在登录页面上,如果我设置如下会话变量:$\u session['user\u id']=$row\u sql['id']它可以工作,但传递到其他页面却不行 我还注意到地址链接改变了域,“www.domain.com”变成了domain.com,但现在我已经使我的.htaccess文件强制它重定向到www.domain.com。然而,在检查我的主机提供商时,我意识到该域显示为“domain.com”。因此,以这样或那样的方式,会话变量不会传递到站点

每次使用登录脚本启动新会话时,会话变量都不起作用。在登录页面上,如果我设置如下会话变量:
$\u session['user\u id']=$row\u sql['id']它可以工作,但传递到其他页面却不行

我还注意到地址链接改变了域,“www.domain.com”变成了domain.com,但现在我已经使我的.htaccess文件强制它重定向到www.domain.com。然而,在检查我的主机提供商时,我意识到该域显示为“domain.com”。因此,以这样或那样的方式,会话变量不会传递到站点上的其他页面

我的.htaccess文件:

RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com$ [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]
我的登录脚本:

<?php

include ("../../connect/connect.php");

$email = $_POST['email']; $pass= base64_encode($_POST['pass']);

$sql = mysqli_query($conn,"select * from users where email = '$email' and pass= '$pass' and status = 1"); 
$total_sql = mysqli_num_rows($sql); 
$row_sql = mysqli_fetch_assoc($sql);

if($total_sql==0) { 
    echo '<script type="text/javascript">alert("incorrect email or password."); window.location.href = "index.php"</script>';       
    exit;   
} 
@session_start(); 
$_SESSION['user_id'] = $row_sql['id']; 
$_SESSION['user_name'] = $row_sql['name']; 
$_SESSION['user_account'] = $row_sql['account']; 
$_SESSION['user_email'] = $row_sql['email'];

if(($row_sql['account']==1) || ($row_sql['account']==2)){
        echo '<script type="text/javascript">window.location.href = "../admin/index.php"</script>';
        exit; }elseif($row_sql['account']==3){  
        echo '<script type="text/javascript">window.location.href = "../1/index.php"</script>';
        exit;
}

?>

因为存在重定向。请检查.htaccess文件中的重定向。“每次我使用登录脚本启动新会话”,好的,让我们从这里开始。你能告诉我们你的代码在那一点上是什么样子吗?很难猜到这个小信息登录脚本到底出了什么问题
<?php 
@session_start();
//-->
error_reporting(-1);
//-->
include ("../../connect/connect.php");
//--> 
$userid = $_SESSION['user_id'];