We help IT Professionals succeed at work.

Check out our new AWS podcast with Certified Expert, Phil Phillips! Listen to "How to Execute a Seamless AWS Migration" on EE or on your favorite podcast platform. Listen Now

x

php cookie question

BR
BR asked
on
Medium Priority
381 Views
Last Modified: 2012-05-11
I have a banner, I want to show it to my user only once a day.

I think cookies the best way for this. ( I use PHP )

I need someting like
if the user has already seen it print nothing
else print the source code of the banner..
what do you suggest? I have try the below code but it didn't work.

setcookie("cookie[one]", "cookieone", time()+86400, '/' ); // one day is 86400 sec.

if ($_COOKIE["cookieone"] = "cookieone")
{
      echo "do not show the banner";
} else {
      echo "show the banner";
}
Comment
Watch Question

See what the COOKIE holds

<?php

setcookie("cookie[one]", "cookieone", time()+86400, '/' ); // one day is 86400 sec.

print_r($_COOKIE);

if (isset($_COOKIE["cookie"]))
{
      echo "do not show the banner";
} else {
      echo "show the banner";
}

?>

Open in new window

Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Dave BaldwinFixer of Problems
CERTIFIED EXPERT
Most Valuable Expert 2014
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
BRDigital Marketing

Author

Commented:
thank you very much
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.