title: login and logout toggle via session
body: <p>hi guys i am doing a school project. i would like to toggle a class when a user is logged in. I have the session working and the javascript is detecting the session but the classes are not toggling. Here is my code</p>
  
  <pre><code>&lt;script language='javascript' type='text/javascript'&gt;
   var userid = "&lt;?php echo $username; ?&gt;";//username is the session variable
   if (userid==(""))//indicaates that no one is logged in
   $('#det_login').toggleClass('hide'); 
   else
   $('#det_logout').toggleClass('hide');
  &lt;/script&gt;
  
  
  &lt;li id="det_login"&gt;&lt;a href="javascript:login('show');" class="nav2"&gt; login&lt;/a&gt;&lt;li&gt;
  
  &lt;li id="det_logout" class="hide"  &gt;&lt;a href="javascript:login2('show');" class="nav2"&gt;&lt;?= $username ?&gt; logout&lt;/a&gt;&lt;li&gt;
  </code></pre>
  
  <p>Please guys I would really appreciate your help. Thank you</p>
  
  <p>Thank for your help guys this is what i did. It was not toggling apparent because i had the javascript above the display statement.</p>
  
  <pre><code>                                &lt;li id="det_login" class="show"   &gt;&lt;a href="javascript:login('show');" class="nav2"&gt;
  login&lt;/a&gt;&lt;li&gt;
  
                           &lt;li id="det_logout" class="show"  &gt;&lt;a href="javascript:login2('show');" class="nav2"&gt;&lt;?= $username ?&gt;
   logout&lt;/a&gt;&lt;li&gt;
  
  &lt;script language='javascript' type='text/javascript'&gt;
   var userid = "&lt;?php echo $username; ?&gt;";
   if (userid==(""))
   {
   $('#det_logout').addClass('hide'); 
    $('#myaccount').addClass('hide');
     $('.divider2').addClass('hide');
   }
   else
  $('#det_login').addClass('hide');
  &lt;/script&gt;
  </code></pre>