Save cookie when you click inside a DIV

Asked

Viewed 124 times

0

I have a DIV, in it goes ads.. and I want you to create a 2-day cookie.. That is, Before loading the page it checks if already clicked somewhere in the DIV in the last 2 days, if already clicked it appears something else in the place of the ad..

but I have to capture this cookie with PHP using IF as the code below.

<?php if ($cookie === sim): ?>
  JA CLICOU
<?php else: ?>
  AINDA N CLICOU
<?php endif; ?>

  • the best way I see it happening would be by using jQuery, so Voce can make a request ajax jQuery.get jQuery.post where Voce treats the user click, when Voce reloads the page Voce queries the cookie via php and passes the value to html. ta using some framework? there are many ways to do this, it would be interesting to post something about your project as well as the existing code

  • I want to make a link protector.. currently soh with bootstrap

  • In the codes of the links above has both reference to how to set a cookie with PHP (including duration), and how to recover a cookie with PHP. If the doubt still persists, please [Dit] your question focusing on the specific part of what you already know/tried and which part exactly is your doubt or difficulty. If there is no solution on the site, the post can be reopened. Or if you have found the solution, but have some doubt not covered by the question, you can leave a comment as well.

  • How to set I know! I already have a code ready to set.. I don’t know how to set these cookies so when I click on a div!

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.