Jump to content

checking 2 arguments


denoteone

Recommended Posts

I want to hide a section of a page if a certain user is not logged in.  I have a basic login page that sets a session to user.

my main page looks something like this

 

<?PHP

session_start();

if(isset($_SESSION['user']))
{
?>
<html>content</html>
<?PHP
}else{
redirect to login because they are not logged in.
} 
?>

 

at this point I need to see if the session is set to user or admin

so I guess something like

 

<?PHP

session_start();
if(isset($_SESSION['user'] or $_SESSION['admin']));       //this is were I am having trouble.
{
?>
<html>everyone sees this content
<?PHP
if (isset($_SESSION['admin']));
  {
   ?>
     content only only admin sees
      </html>
      <?PHP
         }else{
           ?>
             </html>
<?PHP
}elses{
redirect to login besause neither admin or user  is set in the session

 

 

this would let them both view the page and then at the bottom were the extra content for the admin would be I could have another if statement that checks to see if the session is set to admin if not I would just end my html page?

 

what is the syntax to check two arguments and does it look like I am on the right path with this?

 

Link to comment
Share on other sites

If I understand, you have 3 types of logins:

 

1.  Admin

2.  Users

3.  A Specific User

 

using if isset for session admin or user is ok, then a subclause under session users like && $_SESSION['user'] == fred (which you would set when fred logged in) would give you the extra functionality.

 

Please forgive me if I misunderstand the question.  I just wrote the exact script last night for another project LOL.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.