PHP - değişken değerinin garip değişiklikler

0 Cevap php

Bir bu kodu yazdım:

<?php
require("../../config.php");
require("../php/funct.php");

try {
    $pdo = new PDO('mysql:host='.DB_HOST.';dbname='.DB_TABL.';', DB_AUSER, DB_APASS);
}
catch(PDOException $e) {
    echo 'Error: ' . $e->getMessage();
}
$idee=unique_id();
$insystem=true;

include('session_check.php');

unset($insystem);
    print($sesja);  ///// SECOND PRINT()
if($sesja!=1) {
    die("Session error");
    exit;
} else {    
       //some other code
}

session_check.php burada:

<?php
if(isset($insystem) && $insystem) {
    if(!isset($_COOKIE['seid']))    {
        setcookie('seid', $idee, time() + COOKIELIFE);
        $sesja=0;
    } else {
        setcookie('seid', $_COOKIE['seid'], time() + COOKIELIFE);
        $dane=$pdo->prepare('SELECT s.id, s.ip, s.czas, s.prawa, p.nick, p.id FROM sessions s JOIN pracownicy p ON s.Pracownicy_id=p.id WHERE s.id=:id');
        $dane->bindValue(':id',$_COOKIE['seid'], PDO::PARAM_STR);
        $dane->execute();
        $dsesji = $dane -> fetch();
        $dane->closeCursor();
        unset($dane);
        if($dsesji!==false) {
            if(isset($_GET['lo']) && ($_GET['lo']==='lo') && isset($indeks) && $indeks) {
                $usun=$pdo->prepare('DELETE FROM sessions WHERE id=:id');
                $usun->bindValue(':id',$_COOKIE['seid'], PDO::PARAM_STR);
                $usun->execute();
                unset($usun);
                setcookie('seid', 'abc', time() - 42000);
                header("Location: index.php");
            }
            $sesja=1;
            $_nick=$dsesji['nick'];
            $_Pracownicy_id=$dsesji['id'];
            $_prawa=explode('|',$dsesji['prawa']);
            unset($_prawa[count($_prawa)-1]);
            if($dsesji['ip']!=$_SERVER['REMOTE_ADDR']) {
                $usun=$pdo->prepare('DELETE FROM sessions WHERE id=:id');
                $usun->bindValue(':id',$_COOKIE['seid'], PDO::PARAM_STR);
                $usun->execute();
                unset($usun);
                setcookie('seid', 'abc', time() - 42000);
                header("Location: index.php?lo=bs");
                exit;
            }
            $teraz=time();
            $roznica=$teraz-$dsesji['czas'];
            if($roznica>(TIMEOUT*60)) {
                $usun=$pdo->prepare('DELETE FROM sessions WHERE id=:id');
                $usun->bindValue(':id',$_COOKIE['seid'], PDO::PARAM_STR);
                $usun->execute();
                unset($usun);
                setcookie('seid', 'abc', time() - 42000);
                header("Location: index.php?lo=to");
                exit;
            }
            if($sesja!=0) {
                $idee=unique_id();
                setcookie('seid', $idee, time() + COOKIELIFE);
                $dane=$pdo->prepare('UPDATE sessions SET id=:nowyid WHERE id=:id');
                $dane->bindValue(':nowyid',$idee, PDO::PARAM_STR);
                $dane->bindValue(':id',$_COOKIE['seid'], PDO::PARAM_STR);
                $dane->execute();
                unset($dane);
                $_CURR_SID=$idee;
                unset($idee);
            }
            print($sesja);  ///// FIRST PRINT()
        } else {
            $sesja=0;

        }
    }
} else {
    die('aerr1');
}
?>

Sorun: (session_check.php itibaren) 1 Baskı 1 yazdıran - değer ne beklendiğini, ancak ana komut ikinci baskı 0 yazdıran ne $ Sesja değişken bu iki yazıcı adlı arasında değiştirilebilir değildir çünkü benim için garip.

Ne oldu?

0 Cevap