PHP iframe opening more than one session for the same browser

Asked

Viewed 91 times

1

I am working on an Adsense system, and on the same page has several iframes called, the problem is that I need to limit the amount for each page Only because the access is very fast he creates a session for each iframe, I made a counter but it does not solve because for each session he will be in 0 always. I use the browser cookie to give a session a lifetime, so when the user refreshes the page need to renew the amount.

$cookie = $this->input->cookie('token');
    $hash_cookie = substr($this->input->get('wg', TRUE), 0,20);
    if(empty($cookie)){
        $this->input->set_cookie(['name' => 'token', 'value' => random_string('alpha', 6),'expire' => 5]);
        unset($_SESSION['hashs']);
        $_SESSION['hashs'] = [];

    }
    if(empty($_SESSION['hashs'][$hash_cookie])){
        $_SESSION['hashs'][$hash_cookie] =  0;
    }
    if($_SESSION['hashs'][$hash_cookie] < 3)
        $_SESSION['hashs'][$hash_cookie] += 1; 
    else 
        return '';  

1 answer

-1


It was necessary to put a setTimeout in javascript to make the requests because my sessions were being saved in files so the delay in updating.

Browser other questions tagged

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