JS:在客戶端設(shè)置cookie和獲取cookie的函數(shù)
當(dāng)前位置:點(diǎn)晴教程→知識管理交流
→『 技術(shù)文檔交流 』
<script language="javascript"> function setCookie(name, value, expires, path, domain, secure) { var today = new Date(); var expiry = new Date(today.getTime() + 7 * 24 * 60 * 60 * 1000); if(expires==''||expires==null) { expires=expiry; } var curCookie = name + "=" + escape(value) + ((expires) ? "; expires=" + expires.toGMTString() : "") + ((path) ? "; path=" + path : "") + ((domain) ? "; domain=" + domain : "") + ((secure) ? "; secure" : ""); document.cookie = curCookie; } function getCookie(name) { var dc = document.cookie; var prefix = name + "="; var begin = dc.indexOf("; " + prefix); if (begin == -1) { begin = dc.indexOf(prefix); if (begin != 0) return null; } else begin += 2; var end = document.cookie.indexOf(";", begin); if (end == -1) end = dc.length; return unescape(dc.substring(begin + prefix.length, end)); } </script>
該文章在 2010/8/18 22:09:23 編輯過 |
關(guān)鍵字查詢
相關(guān)文章
正在查詢... |