PHP code example of brdev / cookie

1. Go to this page and download the library: Download brdev/cookie library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

brdev / cookie example snippets





use BRdev\Cookie\Cookie;

okie("BRDEV", 3600);

if(true){
    //SET COOKIE STRING OR INT
    $cookie->set("pswd","mypassword");
    //GET COOKIE
    echo $cookie->pswd ."<br><br>";
}

if(false){
    if($cookie->has("user")){
    
        echo "Name: ".$cookie->user["name"]. "<br>";
        echo "Age: ".$cookie->user["age"]. "<br>";
        echo "Genre: ".$cookie->user["genre"]. "<br>";

    }else{
        //SET COOKIE ARRAY
        $cookie->set("user",[
            "name"  => "Stefan Salvatore",
            "age"   => "18",
            "genre" => "Male"
        ]);
    };
}

if(false){
    $cookie->delete("user");
}

if(false){
    $cookie->deleteAll();
}