Jump to content

$_SESSION['level'] = $row['level'] never stores anything


Recommended Posts

when i do $_SESSION['level'] = $row['level']; i would expect what is in my database in the row 'level' should get stored into that. unfortunatly that doesnt happen and i dont know why.

 

when i <? print_r($_SESSION)?>  i get this array - Array ( [level] => [status] => logged [username] => test ) and as you can see level doesnt appear.

 

could someone advise why it doesnt appear?

 

thanks in advance

Either $row['level'] is empty or non-existent or you have some php code that is overwriting $_SESSION['level'], such as if($_SESSION['level'] = '') (one =, an assignment) instead of if($_SESSION['level'] == '') (two ==, a comparison)

 

It would take seeing your relavant code and data that both sets $row['level'] in your database to the expected value, retrieves $row['level'], assigns the value to $_SESSION['level'] and any code that references $_SESSION['level'] up to the point where you determined that is is empty, to be able to determine what the most likely cause of the problem is.

 

Edit: Short answer - you have access to both your database and your code, you should be able to determine at what point your data and variables have the expected value and at what point they don't. I can guarantee that the code between those two points is where the problem is.

thanks for the reply.  on my login page i have these session variables:

 

$_SESSION['level'] = $row['level'];

$_SESSION['status'] = 'logged';

$_SESSION['username'] = $n;

 

on my admin page i have this:

 

<? if($_SESSION['level'] == "Admin") {?>

 

in my database the row 'level' does have Admin in it or Normal so it deffinatly isnt empty.  i have trolled through all my other pages and cant find anything to do with $_SESSION['level'] anywhere else so i cant see why it would be over written.

 

is there any more of the code you would want to see?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.