예제 #1
0
 function clearCookies($noClear = array("LGKS_SESS_SITE", "PHPSESSID", "USER_DEVICE"))
 {
     if ($noClear == null) {
         $noClear = array();
     }
     foreach ($_COOKIE as $a => $b) {
         if (!in_array($a, $noClear)) {
             deleteCookie($a);
         }
     }
 }
예제 #2
0
    //We want to create the cookie
    $email = $_POST["email"];
    $password = $_POST["password"];
    // Check connection
    $conn = mysqli_connect("localhost", "adminID5Rju3", "Rz5h2JWnm4xd", "tweb");
    if ($conn->connect_error) {
        die("Connection failed: " . $conn->connect_error);
    }
    if (isset($email) and isset($password)) {
        startCookie($email, $password, $conn);
        mysqli_close($conn);
        header("Location: index.php");
    }
} else {
    //We want to delete the cookie
    deleteCookie();
    header("Location: index.php");
}
function startCookie($email, $password, $conn)
{
    if (checkSQLInjection($email) and checkSQLInjection($password)) {
        $result = mysqli_query($conn, "SELECT email , password FROM user WHERE email = '{$email}' AND password = '******'");
        if (mysqli_num_rows($result) > 0) {
            setcookie("email", $email, time() + 86400 * 30, "/");
        }
    } else {
        //SQL INJECTION
    }
}
function deleteCookie()
{
예제 #3
0
        break;
        // Show main Cookie Management
    // Show main Cookie Management
    case "showCookies":
    case "editCookies":
        showCookies();
        break;
        // Add a new cookie to user
    // Add a new cookie to user
    case "addCookie":
        $newCookie["host"] = getRequestVar('host');
        $newCookie["data"] = getRequestVar('data');
        addCookie($newCookie);
        break;
        // Modify an existing cookie from user
    // Modify an existing cookie from user
    case "modCookie":
        $newCookie["host"] = getRequestVar('host');
        $newCookie["data"] = getRequestVar('data');
        $cid = getRequestVar('cid');
        modCookie($cid, $newCookie);
        break;
        // Delete selected cookie from user
    // Delete selected cookie from user
    case "deleteCookie":
        $cid = $_GET["cid"];
        deleteCookie($cid);
        break;
}
//****************************************************************************
//****************************************************************************
예제 #4
0
<?php

function deleteCookie($name)
{
    if (isset($_COOKIE[$name])) {
        unset($_COOKIE[$name]);
        setcookie($name, null, -1);
        return true;
    } else {
        return false;
    }
}
var_dump($_COOKIE);
deleteCookie("TestCookie1");
var_dump($_COOKIE);
echo "p";