Hello,
I have a song streaming website, and i want to set a cookie inside a player popup to avoid that users increment the number of times that an album was played every time they access it.
I want the cookie to last at least 6h, but every time i test the code with 1,2 or 5 minutes it never ends in the time that i specify. For example i want it to last 3min and it may take 5 or 2min to end. Cant figure out why, because i used the same cookie code in a none popup window and it worked.
// player.php (POPUP)
<?php
session_start();
include("include/player-functions.php");
uniqueAlbumListens($db,$_GET['id']);
(...)
?>
//player_functions.php
<?php
(...)
function uniqueAlbumListens($db,$id){
if(!isset($_COOKIE["ml".$id])){
updateListens($db,$id);
}
setcookie("ml".$id, "listens", time()+60*2); // 2minutes -> 60*2 ? || 6h -> 60*60*6 ?
}
(...)
?>