$Session with durability

Asked

Viewed 36 times

0

Hello how can I complement the code below to work as follows accurate that the section is destroyed once a day or if the user creates the SESSION on 01/08/2015 if he accesses the same page with that SESSION on 02/08/2015 and it is destroyed only keeping the section valid if its date is the same. Since I need to keep $SESSION['name'] and $_SESSION['user'].

     <?php
    session_start();
    $_SESSION['nomeSecao'] = $secaoNome;
    $_SESSION['usuarioIp'] = $_SERVER["REMOTE_ADDR"]; 


    if(isset($_SESSION['usuario'], $_SESSION['usuarioIp'] ))
    {

// Da Insert + 1 na tabela secao coluna view

    }

    ?>
  • Use cookies for this

1 answer

1


Complementing the Gerep response:

<?php
if (isset($_COOKIE['data_acesso'])) {
    echo 'Você JÁ passou por aqui!';
} else {
    echo 'Você NUNCA passou por aqui.';
    setcookie('data_acesso', date('Y-m-d 00:00:00'), time() + 86400);
}

Browser other questions tagged

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