0

I am trying to debug an error of Notice: Undefined index at line 5,

$res=$conn->query('SELECT _name, _PETeacher FROM classes;');
$_SESSION['pe_cla']=array();
while($row=$res->fetch_assoc())
{
    if ($row['_PETeacher']!=null && $row['_name']!=null && $row['_PETeacher'] == $_SESSION['Reg'])
    {
        $_SESSION['pe_cla'][] = $row['_name'];
    }
}

The same error message also occationally appear at the following line:

<?php if($_SESSION['Privileges'][6]==0){echo 'd-none';}?> href="class_promo.php">

It seems that it has something to do with the $_SESSION['Reg'], maybe it is the login session.

I am thinking that maybe the "session" get reset or expired. How to extend the life of a session?

Can a same user login from multiple device?

mjb
  • 7,649
  • 8
  • 44
  • 60
  • Your 2nd line does not seems right. It will echo d-none in nothing. I see you have href after it, but d-none is not echoed in any HTML attribute. – ikiK Apr 19 '21 at 01:16
  • You don't have the full PHP code for the page showing, but are you "starting" the session on each page before attempting to access session variables? https://www.php.net/manual/en/reserved.variables.session.php Also, not sure what you mean by "can a same user login from multiple device?" - are you referring to trying to access the same "session" variable values across multiple devices? – Craig Apr 19 '21 at 01:17
  • Do the reporting indexes exist? `Can a same user login from multiple device?` depends on your application logic. `$_SESSION` on its own does nothing to limit it – user3783243 Apr 19 '21 at 01:33

0 Answers0