Making A Message Appear Once In Wordpress

Discussion in 'PHP' started by joebeaven, Oct 2, 2008.

  1. #1
    Hi,

    I'm trying to get a message similar to a popup to appear when anyone visits my Wordpress blog and then not appear for that same user for another 60 hours.

    The message appears OK, but it does so every time a page from the site is loaded in that session, it doesn't wait the 60 hours.

    I've attached the header.php file from my Wordpress theme and a file called cookiemanager.php which is also used as part of the process. Please could someone take a look and tell me what I've done wrong and how to correct it?

    Thanks,
    Joe
     

    Attached Files:

    joebeaven, Oct 2, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    Change this

    
    	if ($_COOKIE[$trackingCode] == "visited") {
    		return "";
    	} else {
    		return "showSqueezePage();";
    	}
    
    PHP:
    into this and try again

    
    	if (isSet($_COOKIE[$trackingCode])) {
    		return "";
    	} else {
    		return "showSqueezePage();";
    	}
    
    PHP:
    Why? if the cookie has expired it will be removed! or not used anymore! only validate cookie content when you need to know certain this from this user (views on pages, last url, etc)
     
    EricBruggema, Oct 3, 2008 IP
  3. joebeaven

    joebeaven Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for the help Eric, but it's still not working correctly. Now I get the message the first time in Firefox and after that I get a message with a 404 error. In IE I get the message the first time and then I get a little image missing symbol which when I click on it I get a 404 error and when I close that page I get a message saying [object Error].

    Have you get any other ideas for what I can do?

    Thanks again,
    Joe
     
    joebeaven, Oct 3, 2008 IP
  4. singh.ajit05

    singh.ajit05 Peon

    Messages:
    83
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    try this

    if ( (isSet($_COOKIE[$trackingCode])) && ($_COOKIE[$trackingCode]!="")) {
     
    singh.ajit05, Oct 3, 2008 IP
  5. joebeaven

    joebeaven Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I added the code and now it's alternating between the message and the 404 page on each visit to any page on the blog.
     
    joebeaven, Oct 3, 2008 IP
  6. joebeaven

    joebeaven Guest

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    It might be helpful to have a look at the site. You can see it here: uklocalelectrician.co.uk
     
    joebeaven, Oct 7, 2008 IP