本人用jsp做了一个简易的bbs论坛网站,利用cookies存储用户数据,实现一个注销功能,类似csdn论坛的注销,即清除cookies中的数据。重新访问首页时不会显示个人信息。请问各位该如何实现?

解决方案 »

  1.   

    cookie.setxxx
    有关时间的函数,忘记是啥了
    response.xxxxxxxxx
      

  2.   

    setMaxAge
    public void setMaxAge(int expiry)
    Sets the maximum age of the cookie in seconds.  
    A positive value indicates that the cookie will expire after that many seconds have passed. Note that the value is the maximum age when the cookie will expire, not the cookie's current age.  A negative value means that the cookie is not stored persistently and will be deleted when the Web browser exits.
     A zero value causes the cookie to be deleted.  
    当你设置cookie的生命周期值1,为正数的时候,那么就会生存你所指定的时间;2:为负数的时候,将会在浏览器退出的时候清除掉;3:如果设置为0那么立即清理掉
     
     
      

  3.   


    //删除cookie
        function removeCookie(name){
            document.cookie = name+"=;expires="+(new Date(0)).toGMTString();
        }
      

  4.   


    把COOKIE的时间 TIMEOUT设置为-1 负数即可。