Calling a PHP page once only
Posted: Wed Nov 29, 2017 12:21 am
I have my "homepage.html" page and need to call a PHP script that makes an entry into a log on the server for each visit.
I need the log to make only a single entry per visit / session.
I inserted the following code into the HTML page just before the /body> tag.
<div id="insert-file"></div>
<script type="text/javascript">
$(document).ready(function()
{
$('#insert-file').load('http://www.xxxx.xxxx/log.php');
});
</script>
It works fine and does the job, BUT - it keeps executing it each time the user comes back to the home page....
1) Is the above code OK?
2) How can I enforce it to only execute ONCE per visitor's session
I need the log to make only a single entry per visit / session.
I inserted the following code into the HTML page just before the /body> tag.
<div id="insert-file"></div>
<script type="text/javascript">
$(document).ready(function()
{
$('#insert-file').load('http://www.xxxx.xxxx/log.php');
});
</script>
It works fine and does the job, BUT - it keeps executing it each time the user comes back to the home page....
1) Is the above code OK?
2) How can I enforce it to only execute ONCE per visitor's session