Home > Back-end >  $_SESSION['exist']=true even if not set
$_SESSION['exist']=true even if not set

Time:03-12

i'm about to update my website and since i have offshored some code it want work anymore...

My problem now is, that i want to update the stats, when a new user visits my site but it doesn't go into the if, because the $_SESSION['exist'] is just true, even if not stated.

My code looks like this:

<?php
session_start();

if(!isset($_SESSION['exist'])){ //it doesn't go in this if
    $_SESSION['exist'] = true;

    $today = date("Y/m/d");
    require(__DIR__ . '/./functions/select/stats/daily_view.php');
    $dailyview = selectDailyView();
    echo $dailyview['date'];
    if($dailyview['date'] != $today){
        //start COPY
        $dv = selectDailyView();
        require_once(__DIR__ . '/./functions/insert/stats/dailyview.php');
        insertDailyView($dv[0]['date'], $dv[0]['dailyview']);
        //end COPY
        require_once(__DIR__ . '/./functions/update/stats/reset_daily_view.php');
        updateResetDailyviewDate($today);
    }

    require_once(__DIR__ . '/./functions/update/stats/stats.php');
    updateStat('index');

    require_once(__DIR__ . '/./functions/update/stats/dailyview.php');
    updateDailyView();
}
?>

So i tried to comment out everything except the session_start(); and to see whats stored in the $_SESSION i wrote a var_dump($_SESSION); and it says

array(1){["exist"]=>bool(true)}

I tried to clear the cache, unset the $_SESSION, destroy the session... Nothing worked. With unset($_SESSION); the output is NULL, but when i delete that line and reload the page the output still says

array(1){["exist"]=>bool(true)}

Do you have any idea?

CodePudding user response:

You have to unset it :

unset($_SESSION['exist']);
  • Related