WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : Cookie Set and Unset PHP script
Categories : PHP, Cookies Update Picture
Benjamin Baez
Date : May 07th 2000
Grade : 4 of 5 (graded 2 times)
Viewed : 32710
File : cookie.array.test.php
Images : No Images for this code example.
Search : More code by Benjamin Baez
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<?
function store_array_in_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()+3600*5, "/");
unset($tmpstring);
}

function erase_array_in_cookie($cookiename, $array2store) {
$tmpstring = serialize($array2store);
setcookie($cookiename, $tmpstring, time()-3600*5, "/");
unset($tmpstring);
}
function erase_set_array_cookie($cookiename, $array2store) {
        $tmpstring = serialize($array2store);
        setcookie($cookiename, $tmpstring, time()-604800, "/");
        setcookie($cookiename, $tmpstring, time()+604800, "/");
        
        unset($tmpstring);
}
function erase_set_array_cookie_header($cookiename, $array2store) {
        $time = mktime()+36000;
        $backtime = mktime()-36000;
        $date = date("l, d-M-y H:i:s", ($time));
        $backdate = date("l, d-M-y H:i:s", ($backtime));
        $tmpstring = serialize($array2store);
        $tmpstring = urlencode($tmpstring);
        // header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/; domain=.biospectra.net\n");
        // header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/; domain=.biospectra.net\n");
        // header("Location: http://www.biospectra.net/index.php3\n");
        // exit;

        header("Set-Cookie:$cookiename=$tmpstring;expires=$backdate GMT;path=/\nSet-Cookie:$cookiename=$tmpstring;expires=$date GMT;path=/");
        unset($tmpstring);
}
function erase_cookie_header($cookiename, $array2store) {
        $backtime = mktime()-36000;
        $backdate = date("l, d-M-y H:i:s", ($backtime));
        $tmpstring = serialize($array2store);
        $tmpstring = urlencode($tmpstring);
        header("Set-Cookie: $cookiename=$tmpstring; expires=$backdate GMT; path=/");
        unset($tmpstring);
}
function store_cookie_header($cookiename, $array2store) {
        $time = mktime()+36000;
        $date = date("l, d-M-y H:i:s", ($time));
        $tmpstring = serialize($array2store);
        $tmpstring = urlencode($tmpstring);
        header("Set-Cookie: $cookiename=$tmpstring; expires=$date GMT; path=/");
        unset($tmpstring);
}
function get_array_from_cookie($cookiename) {
$tmpstring = "global \$$cookiename";
eval($tmpstring);
unset($tmpstring);

if (isset(${$cookiename})) {
                 $tmparray=unserialize(stripslashes(${$cookiename}));
} else {
                 $tmparray = array();
}
while (list($name, $value) = each($tmparray))
printf("type=\"hidden\" name=\"%s\" value=\"%s\"<BR>\n", $name, $value);
return $tmparray;
}
$cookiename="cookiearray";
if (!($submit_store == "")) {
        //$array2store=array(handle,password,reg_id,personals_reg,high_school_reg);
        $array2store=array(bbaez,nim101,15,0,0);
        store_array_in_cookie($cookiename, $array2store);
        };
if (!($submit_erase == "")) {
        $array2store=array(bbaez,nim101,15,1,1);
        erase_array_in_cookie($cookiename, $array2store);
        };
if (!($submit_erase_store_set == "")) {
        $array2store=array(bbaez,nim101,15,1,1);
        erase_set_array_cookie($cookiename, $array2store);
        };
/**********************************************************************************/
if (!($submit_store_header == "")) {
        $array2store=array(bbaez,nim101,15,0,0);
        store_cookie_header($cookiename, $array2store);
        };
if (!($submit_erase_store_header == "")) {
        $array2store=array(bbaez,nim101,15,1,1);
        erase_set_array_cookie_header($cookiename, $array2store);
        };
if (!($submit_erase_header == "")) {
        $array2store=array(bbaez,nim101,15,1,1);
        erase_cookie_header($cookiename, $array2store);
        };
/**********************************************************************************/
if (!($submit_retrieve == "")) {
        get_array_from_cookie($cookiename);
        };
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<TITLE> New Document </TITLE>
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="">
<META NAME="Keywords" CONTENT="">
<META NAME="Description" CONTENT="">
</HEAD>

<BODY BGCOLOR="#FFFFFF">
<form action="<? echo $PHP_SELF ?>" method="POST">

<input type="submit" name="submit_store" value="Click To Store">
<input type="submit" name="submit_erase_store_set" value="Click To Erase and Store Using setcookie()">
<input type="submit" name="submit_erase" value="Click To Erase">
<P>
<P>
<input type="submit" name="submit_store_header" value="Click To Store Using the Header">
<input type="submit" name="submit_erase_store_header" value="Click To Erase and Store Using Header">
<input type="submit" name="submit_erase_header" value="Click To Erase Using the Header">
<P>
<P>
<input type="submit" name="submit_retrieve" value="Click To Retrieve">
</form>
</BODY>
</HTML>



Make old style (PHP3) scripts using GET, POST, COOKIE and File uploads (POST) compatible with PHP 4.2.0
Categories : PHP, HTML and PHP, Global Variables, Cookies, Variables
Function that allows a Javascript cookie to be set after HTML has been outputted to the page.
Categories : PHP, Java Script, Cookies, HTML and PHP
Complete, simple working example of login screen and check on a unique page using php functions, cookies and mysql database.
Categories : PHP, Cookies, MySQL, HTML and PHP, Authentication
The Best Authorize
Categories : PHP, MySQL, Cookies
Secure Login
Categories : PHP, MySQL, Cookies, Security
Simple Cookie example
Categories : PHP, Beginner Guides, Cookies
This functions makes it easy to use session-variables known from ASP. With one Cookie the array "session" will save and restore from a db-record. In this version MySQL is used but it's should very easy to change
Categories : PHP, Arrays, Cookies, MySQL, Databases
Cross Browser Session Starter
Categories : PHP, Sessions, Cookies
PHP4 MYSQL Authentication Script with cookie. Short & Sweet
Categories : Authentication, Apache, Cookies, PHP, MySQL
A flat file counter
Categories : PHP, Cookies, Filesystem, Beginner Guides
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
PHP Cookies - Simple cookie write/read methods that allow basic encryption
Categories : PHP, Cookies, Security, Encryption
Multilingual php webpage
Categories : PHP, Languages, Cookies
Smart Counter - This little script is a plain and simple hit counter that uses cookies to determine whether or not the visitor has already been counted.
Categories : Cookies, HTML and PHP, PHP
Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel