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
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
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



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 : Store, retrieve and delete cookies using JavaScript.
Categories : Java Script, Cookies, Beginner Guides, Cookies Click here to Update Your Picture
Bobin R
Date : Jan 26th 2007
Grade : 4 of 5 (graded 7 times)
Viewed : 39036
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Bobin R
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

<!doctype html public "-//w3c//dtd html 4.01 transitional//en">
<html>
<head>
<title>Cookie Functions</title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<script type="text/javascript">
<!--
/*
Functions for storing, retrieving and deleting cookies
*/

function getCookie(name) {
    var sPos = document.cookie.indexOf(name + "=");
    var len = sPos + name.length + 1;
    if((!sPos) && (name != document.cookie.substring(0, name.length))){
        return null;
    }
    if(sPos == -1){
        return null;
    }
    var ePos = document.cookie.indexOf(';', len);
    if(ePos == -1) ePos = document.cookie.length;
    return unescape(document.cookie.substring(len, ePos));
}

function setCookie(name, value, expires, path, domain, secure){
    var today = new Date();
    if(expires){
        expires = expires * 1000 * 3600 * 24;
    }
    document.cookie = name+'='+escape(value) +
        ((expires) ? ';expires=' + new Date(today.getTime() + expires).toGMTString() : '') +
        ((path) ? ';path=' + path : '') +
        ((domain) ? ';domain=' + domain : '') +
        ((secure) ? ';secure' : '');
}

function deleteCookie(name, path, domain){
    if(getCookie(name)){
        setCookie(name, '', -30, path, domain);
    }
}
function testFunction(){
    var c = parseInt(getCookie('Value'));
    if(!c){
        alert('No initial Value\nSetting New Cookie\nValue : 0');
        setCookie('Value', 1);
    }else{
        alert('Stored Cookie\nValue : ' + c);
        alert('Setting New Cookie\nValue : ' + (c + 1));
        setCookie('Value', (c + 1));
    }
    //deleteCookie('Value');
}
//-->
</script>
</head>

<body onload="testFunction()">

</body>
</html>



Run a function once per session.
Categories : Beginner Guides, Java Script, Cookies
Simple Cookie example
Categories : PHP, Beginner Guides, Cookies
A very simple PHP single password cookie based login without usernames.
Categories : PHP, Cookies, Security, Beginner Guides
A flat file counter
Categories : PHP, Cookies, Filesystem, Beginner Guides
Simple PHP cookie counter
Categories : PHP, Cookies, Beginner Guides
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
Easy alert box pop-up function
Categories : PHP, Java Script, Beginner Guides
With this class you can use cookies with chips
Categories : PHP, Cookies
Show or Hide your Content using Javascript
Categories : Java Script, HTML, CSS, Beginner Guides
Show and Hide Tables, Table Rows, Form Elements Etc.
Categories : Java Script, Beginner Guides
Function that does language negotiation based on the Accept-Language header, a cookie or host name
Categories : HTTP, PHP, Cookies
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
Example voting script. Lets people enter suggestions and vote for existing ones.
Categories : MySQL, PHP, Cookies, Complete Programs, Databases
Conditional Check - a script that allows a user to submit a form only if the user check a checkbox.
Categories : HTML, Java Script, Form Processing, Beginner Guides
Ajax - Perform a simple server side request and update the current HTML page.
Categories : AJAX, Java Script, Beginner Guides
 Ken Douglass wrote :1766
thanks!