<!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 A very simple PHP single password cookie based login without usernames. Categories : PHP , Cookies , Security , 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 A flat file counter Categories : PHP , Cookies , Filesystem , Beginner Guides Simple Cookie example Categories : PHP , Beginner Guides , Cookies Ajax - Perform a simple server side request and update the current HTML page. Categories : AJAX , Java Script , Beginner Guides Fancy Quick Access Navigation Link Categories : Java Script , Navigation , User Interface , DHTML , Beginner Guides Show hide table rows to make dynamic forms Categories : Beginner Guides , Java Script , Form Processing , HTTP Cross Browser Session Starter Categories : PHP , Sessions , 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 Changing the Style of form objects using the JavaScript OnClick method. Categories : Java Script , Form Processing , Beginner Guides , CSS Validating a URL with JavaScript RegExp Categories : Java Script , Data Validation , Beginner Guides PHP Cookies - Simple cookie write/read methods that allow basic encryption Categories : PHP , Cookies , Security , Encryption Authentication script to authenticate users in Active Directory through LDAP. Categories : LDAP , Authentication , Cookies , PHP
Ken Douglass wrote : 1766
thanks!