|
|
|
|
Like this code?
Show the author your appreciation.
|
|
| |
This codes set and gets cookies and also, if cookies are not set in the browser, it shows a page to warn member.
|
function setCookie(c_name,value,expiredays)
{
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
if (document.cookie.length<=0)
location="jscookietest.php?cookie=0";
}
function getCookie(c_name)
{
if (document.cookie.length>0)
{
c_start=document.cookie.indexOf(c_name + "=");
if (c_start!=-1)
{
c_start=c_start + c_name.length+1;
c_end=document.cookie.indexOf(";",c_start);
if (c_end==-1) c_end=document.cookie.length;
return unescape(document.cookie.substring(c_start,c_end));
}
}
return "";
}
function issetCookie(c_name)
{
value=getCookie(c_name);
if (value!=null && value!="")
{
return 1;
}
else
{
return 0;
}
}
function deleteCookie ( cookie_name )
{
var cookie_date = new Date ( ); // current date & time
cookie_date.setTime ( cookie_date.getTime() - 1 );
document.cookie = cookie_name += "=; expires=" + cookie_date.toGMTString();
} | | |
|
| Get your browser details using javascript Categories : Java Script, Beginner Guides, Browsers | | | JavaScript dropdown list menu to switch any page. Categories : Java Script, Beginner Guides, Form Processing | | | Easy alert box pop-up function Categories : PHP, Java Script, Beginner Guides | | | Local Time clock and Server time usign PHP and JavaScript Categories : PHP, Java Script, Date Time, Beginner Guides | | | Store, retrieve and delete cookies using JavaScript. Categories : Java Script, Cookies, Beginner Guides, Cookies | | | Form Processing : with alert Highlight field name which is not filled by user Categories : Java Script, Form Processing, Data Validation, Beginner Guides, Web Design | | | Show hide table rows to make dynamic forms Categories : Beginner Guides, Java Script, Form Processing, HTTP | | | Fancy "Quick Access" Navigation Link Categories : Java Script, Navigation, User Interface, DHTML, Beginner Guides | | | Show and Hide Tables, Table Rows, Form Elements Etc. Categories : Java Script, Beginner Guides | | | Simple Javascript CSS Digital Clock Categories : Java Script, Date Time, CSS, Beginner Guides, Web Design | | | Show or Hide your Content using Javascript Categories : Java Script, HTML, CSS, Beginner Guides | | | Validating a URL with JavaScript RegExp Categories : Java Script, Data Validation, Beginner Guides | | | Newbie Notes #9 - Hyperlinking a post Categories : PHP, Java Script, HTML and PHP, Beginner Guides | | | 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 | | | Changing the Style of form objects using the JavaScript OnClick method. Categories : Java Script, Form Processing, Beginner Guides, CSS | |
|
|