I am trying to display a div only if the user is logged in, therefore only if $_SESSION['MM_Username'] exists and is equal to something so to achieve this I came up with the following code. The session variables are set and I know they exist however when I log out I still see the div:
<ul id="example-1" class="sticklr" style="list-style:none;display:<?php if ($_SESSION['MM_Username']=='' & $_SESSION['MM_Username']==NULL){echo('none');}?>">
How can I debug this to see whats the problem, or if someone knows a better way to display a div only if user is logged in please let me know .
To check if a variable is set in PHP you can use the
isset()function:empty()checks if there is a value associated with the variable: http://php.net/emptySource: http://php.net/isset
One cool thing about
isset()is that it won’t throw an error or warning message when you ask if a variable is set that is not.