PHP session variable undefined

后端 未结 3 1841
清酒与你
清酒与你 2021-01-27 13:26

I have this session variable which i am trying to set to an access level when the users logs in with this:

 $accessquery = mysql_query(\"SELECT roleid FROM perso         


        
相关标签:
3条回答
  • 2021-01-27 13:31

    Two possibilities here :

    1. Start the session by using session_start(); at the begining of page.
    2. use the following code:

      $accessquery = mysqli_query($conn, "SELECT roleid FROM person WHERE email = '". $email ."'", mysqli_store_result($conn));
      
      $access = mysqli_fetch_row($accessquery);
      
      $_SESSION['Access'] = $access[0];
      
    0 讨论(0)
  • 2021-01-27 13:34

    Did you call session_start();?

    Try to debug your code with just a fixed value: $_SESSION["Test"]="test"; and then do a var_dump($_SESSION);

    0 讨论(0)
  • 2021-01-27 13:43

    To figure out what's going on, I recommend you to use

    print_r($any_variable);
    

    See http://php.net/print_r

    0 讨论(0)
提交回复
热议问题