最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
cookie实现自动登录功能:
时间:2009-09-04 编辑:简简单单 来源:一聚教程网
cookie实现自动登录功能:
01.function getCookie( name ) { 02. var start = document.cookie.indexOf( name + "=" ); 03. var len = start + name.length + 1; 04. if ( ( !start ) && ( name != document.cookie.substring( 0, name.length ) ) ) { 05. return null; 06. } 07. if ( start == -1 ) return null; 08. var end = document.cookie.indexOf( ';', len ); 09. if ( end == -1 ) end = document.cookie.length; 10. return unescape( document.cookie.substring( len, end ) ); 11.} 12.function setCookie( name, value, expires, path, domain, secure ) { 13. var today = new Date(); 14. today.setTime( today.getTime() ); 15. if ( expires ) { 16. expires = expires * 1000 * 60 * 60 * 24; 17. } 18. var expires_date = new Date( today.getTime() + (expires) ); 19. document.cookie = name+'='+escape( value ) + 20. ( ( expires ) ? ';expires='+expires_date.toGMTString() : '' ) + //expires.toGMTString() 21. ( ( path ) ? ';path=' + path : '' ) + 22. ( ( domain ) ? ';domain=' + domain : '' ) + 23. ( ( secure ) ? ';secure' : '' ); 24.} 25.function deleteCookie( name, path, domain ) { 26. if ( getCookie( name ) ) document.cookie = name + '=' + 27. ( ( path ) ? ';path=' + path : '') + 28. ( ( domain ) ? ';domain=' + domain : '' ) + 29. ';expires=Thu, 01-Jan-1970 00:00:01 GMT'; 30.} |
-
上一个: js计算时分秒代码
-
下一个: Javascript自定义函数
相关文章
- HTML简单购物数量小程序代码展示 10-31
- html canvas实现弹幕功能 10-31
- HTML中空格表示的意义 10-31
- html area标签解读 10-31
- html使用表单标签实现注册页面代码展示 10-31
- 使用HTML截图并保存为本地图片的代码展示 10-31