#native_company# #native_desc#
#native_cta#

Magic Cookie

By Steven Chalker
on January 19, 2002

Version: 1.0

Type: Full Script

Category: HTTP

License: GNU General Public License

Description: This is a secret script; but I’ll explain anyway. This stores the code in your harddrive. It is like Sessions.

<?php
// Example:
$cookies = new magiccookie();
$cookies->set("retrieved","hello");
$cookies->delete("retrieved");
echo $cookies->cookie("retrieved");

// Use "retrieved" as a PHP Tag
$cookies->parse();
echo $retrieved;

// -----
class magiccookie {
function magiccookie() {
$fp=fopen("C:Cookies.txt","a+"); fclose($fp);
}
function set($name,$value) {
$fp=fopen("C:Cookies.txt","w");
fwrite($fp,$name."=".$value.";"); fclose($fp);
}
function delete($name) {
$fp=fopen("C:Cookies.txt","a+");
$fil=fread($fp,filesize("C:Cookies.txt"));
$fil=str_replace($name,"DELETEDCOOKIE",$fil);
fwrite($fp,$fil);
}
function cookie($name) {
$fp=fopen("C:Cookies.txt","r");
parse_str(fread($fp,filesize("C:Cookies.txt")));
return $$name;
}
function parse() {
$fp=fopen("C:Cookies.txt","r"); $R=fread($fp,filesize("C:Cookies.txt")); fclose($fp);
parse_str($R);
}
?>