1.
function check(){
if( window.navigator.cookieEnabled)
return true;
else{
alert("Browser configuration error, Cookie is not available!");
return false;}
}
2.
SetCookie('cookie_test' ,'1');
var cookie_test = getCookie('cookie_test');
if( '1' != cookie_test)
{
alert('not supported');
} else
{
alert('support');
}
function SetCookie(name,value)//Two parameters, one is the name of the cookie and the other is the value
{
var Days = 30; //This cookie will be saved for 30 days
var exp = new Date(); //new Date("December 31, 9998");
exp.setTime( exp.getTime() Days*24*60*60*1000);
document.cookie = name "=" escape (value) ";expires=" exp.toGMTString();
}
function getCookie(name)//Get cookies function
{
var arr = document.cookie.match(new RegExp("(^| )" name "=([^;]*)(;|$)" ));
if(arr != null) return unescape(arr[2]); return null;
}
function delCookie(name)//Delete cookie
{
var exp = new Date();
exp.setTime(exp.getTime() - 1);
var cval=getCookie(name);
if(cval!=null) document.cookie= name "=" cval ";expires=" exp.toGMTString();
}
3.
var cookieEnabled=(navigator.cookieEnabled)? true : false
//Determine whether cookies are turned on
//If browsing The server is not ie4 or ns6
if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled){
document.cookie="testcookie"
cookieEnabled=(document.cookie=="testcookie")? true : false
document.cookie="" //erase dummy value
}
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn