How to stop ads being shown for logged in members

Discussion in 'Programming' started by pictureboarduk, Aug 10, 2009.

  1. #1
    Hi,

    I'm modifying a PHP/MySQL driven site which currently has ads hardcoded into the HTML of the pages.

    I've decided to add PHP sessions and want to remove the ads being shown for people who are logged in.

    I was hoping for some advice on how this is normally done. I'm doing the coding by hand.

    Thanks for any help!

    :)
     
    pictureboarduk, Aug 10, 2009 IP
  2. LinkBliss

    LinkBliss Peon

    Messages:
    697
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Logged into what? I guess I don't understand.

    If it is all custom written, you would know who is logged in, correct? Then you would just use a conditional.

    Eric
     
    LinkBliss, Aug 10, 2009 IP
  3. premiumscripts

    premiumscripts Peon

    Messages:
    1,062
    Likes Received:
    48
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, assuming you set a user id in the session once a user is logged in, it would be as simple as this:

    if (!empty($_SESSION['user_id'])) { 
       //logged in 
    } else { 
       //not logged in 
    }
    PHP:
     
    premiumscripts, Aug 10, 2009 IP
  4. nomzz

    nomzz Well-Known Member

    Messages:
    475
    Likes Received:
    9
    Best Answers:
    0
    Trophy Points:
    110
    #4
    yes it should be simple , the logic which your using to check logged in for members should be applied to banners
     
    nomzz, Aug 11, 2009 IP
  5. jamespv85

    jamespv85 Peon

    Messages:
    238
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Hardcoded you say? Uugghh that's gotta be a lot of work and headaches. I hope the banners/ads have divs of their owns so it's at least easier.

    If you can or have identified these, it's just then a matter of putting in a condition that hides these divs/sections once a member has logged in.
     
    jamespv85, Aug 11, 2009 IP
  6. jjwdesign

    jjwdesign Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    I second the mention of $_SESSION.

    I question you really need answered is found in the code. Look for a user class or setup of user functions. Then search for any $_SESSION variables, such as, $_SESSION['logged_in'] or $_SESSION['valid']. Once you figure out how the program is validating a "logged-in" user, you can write the "If/Then/Else" statement logic into your header code.

    Cheers,
    Jeff
     
    jjwdesign, Aug 11, 2009 IP
  7. kblessinggr

    kblessinggr Peon

    Messages:
    539
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #7
    Third Mentioned.

    :p IF it's hard coded well you have no choice but to make those fields dynamic, or at the very least place the appropriate if(){ .. } php blocks around the ad placement to accommodate the turning off of the ads. But I would strongly recommend converting to some kind of system that allows you to dynamically manager you ads.
     
    kblessinggr, Aug 11, 2009 IP