Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6936747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T12:16:25+00:00 2026-05-27T12:16:25+00:00

I am trying to display a div only if the user is logged in,

  • 0

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 .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T12:16:25+00:00Added an answer on May 27, 2026 at 12:16 pm

    To check if a variable is set in PHP you can use the isset() function:

    <?php
    
    //this checks to see if the variable isset and not null, if it is not set or is null then echo 'none';
    if (!isset($_SESSION['MM_Username']) || empty($_SESSION['MM_Username'])){
        echo 'none';
    }
    
    ?>
    

    empty() checks if there is a value associated with the variable: http://php.net/empty

    If a variable has been unset with unset(), it will no longer be set.
    isset() will return FALSE if testing a variable that has been set to
    NULL. Also note that a NULL byte (“\0”) is not equivalent to the PHP
    NULL constant.

    Source: 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to use prototype and scriptaculous to hide and display a div element
Using jQuery, I am trying to capture and display the value of a div
Trying to display current time with PHP (using this ): $date = date('m/d/Y h:i:s
Im trying to display some files in a web page so the user can
I am trying to only fetch the first record in my table for display.
I'm trying to display the following code only once while the rest of the
I'm trying to display a flash when a user visits a page which thanks
I am trying to achieve a modal overlay using jQuery. When a user clicks
Hi everyone, here am trying to display the source code of a particular div
I'm trying to display a number of images in an absolutely positioned div. The

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.