开发者

How do I use PHP to display confirmation tracking code only once w/o using a database?

开发者 https://www.devze.com 2023-04-11 06:45 出处:网络
How do I make it so the tracking code only runs once...and isn\'t triggered again on a refresh? I searched but it seems almost always people are saying to use a database...but I was hoping to avoid t

How do I make it so the tracking code only runs once...and isn't triggered again on a refresh?

I searched but it seems almost always people are saying to use a database...but I was hoping to avoid that....is it possible?

Thanks开发者_JAVA百科

here is the solution for future searchers:

before <HTML> put: <?php session_start(); ?>

Then do this:

<?php
if($_SESSION['check']!=1)
{
$_SESSION['check']=1;
echo '<div class="show">tracking code</div>';}
?> 


There are a number of options available to accomplish this. You can use a flag variable in $_SESSION, you can use in-browser storage with HTML5, or a Javascript DB like http://taffydb.com/. $_SESSION flag variables would probably be the easiest since it doesn't require you to research much more than you already know.

Good luck!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号