Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Question - $_SESSION

    Hello!

    I was wondering if you guys could help me out with something. If I wanted to check if a users level was either level 1 or 2 to do something on my website would I have to make two if statements or could I just simply do this:

    PHP Code:

    <?php

     
    if($_SESSION['level'] == 12) {
     
     
    // allow this action to happen
     
      
    }
      else 
      {
      
      
    // Nothing happens.
      
      
    }

    ?>
    Thank for the help guys!

    Jon W

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,852
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    if(in_array($_SESSION['level'],array(1,2)))
    or simlpy
    Code:
    if($_SESSION['level']==1 || $_SESSION['level'] ==2)
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Ok thanks.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •