Blogger Information
Blog 14
fans 0
comment 0
visits 27813
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js操作cookie
花式BUG_beisi
Original
624 people have browsed it

jquery.cookie.js插件:  

      

    <script type="text/javascript" src="js/jquery-1.6.2.min.js"></script>  

    <script type="text/javascript" src="js/jquery.cookie.js"></script>   

      

    新增cookie:  

        $.cookie('cookieName', 'cookieValue');    

        注:如果没有设置cookie的有效期,则cookie默认在浏览器关闭前都有效,故被称为"会话cookie"。  

          

        // 创建一个cookie并设置有效时间为7天:  

        $.cookie('cookieName', 'cookieValue', { expires: 7 });  

          

        // 创建一个cookie并设置cookie的有效路径:  

        $.cookie('cookieName', 'cookieValue', { expires: 7, path: '/' });  

          

    读取cookie:  

        $.cookie('cookieName'); // 若cookie存在则返回'cookieValue';若cookie不存在则返回null   

          

    删除cookie:把ncookie的值设为null即可  

        $.cookie('the_cookie', null); 


Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post