Login   Register  
PHP Classes
elePHPant
Icontem

File: example/cookie.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nathan Lucas  >  Cipher  >  example/cookie.php  >  Download  
File: example/cookie.php
Role: Example script
Content type: text/plain
Description: Cookie example.
Class: Cipher
Encrypt and decrypt data with a single key
Author: By
Last change: Changed example with a more practical one.
Date: 6 years ago
Size: 396 bytes
 

Contents

Class file image Download
<?php
require_once("./Cipher.php");
$cipher = new Cipher;

if (!isset(
$_COOKIE['c_data'])) {
    
$data $cipher->encrypt("some data""a key");
    
$iv $cipher->getIV();

    
setcookie("c_data"$datatime()+3600);
    
setcookie("c_iv"$ivtime()+3600);
} else {
    
$iv $_COOKIE['c_iv'];
    
$data $_COOKIE['c_data'];
    echo 
$cipher->decrypt($data"a key"$iv);
}
?>